【问题标题】:“has no attribute 'reduce_cython” error when using Pyinstaller exe使用 Pyinstaller exe 时出现“没有属性 'reduce_cython”错误
【发布时间】:2019-07-24 05:06:28
【问题描述】:

我使用 pyinstaller 将我的 Python 文件转换为 exe。执行时出现以下错误,

AttributeError: type object 'neuralcoref.neuralcoref.array' 没有 属性 'reduce_cython' 我使用的是 Python 3.6.7,Pyinstaller 4.0, NeuralCoref 4、Spacy 2.1.0、Cython 0.27.3。

有什么建议可以解决这个问题或将 .py 转换为 exe 的更好方法吗?我尝试过 py2exe、Cxfreee 但不起作用。

我的代码的最小版本:

import neuralcoref
def ApplyCorefResolutionToPreProcessedMail(text, nlp):
    # load NeuralCoref and add it to the pipe of SpaCy's model
    coref = neuralcoref.NeuralCoref(nlp.vocab) 
    nlp.add_pipe(coref, name='neuralcoref')
    doc = nlp(text)
    corefresolvedmail = doc._.coref_resolved
    return corefresolvedmail

我在下面附上了堆栈跟踪,

【问题讨论】:

  • 给我们你的代码的最小版本。
  • 嗨@M.R.我在问题中添加了代码的最小版本
  • 此链接对您有帮助吗? github.com/cython/cython/issues/1953
  • 函数怎么调用(加到代码里),直接运行脚本也报错吗?
  • 脚本直接运行时运行良好。但是 Pyinstaller 生成的可执行文件会抛出指定的错误。

标签: python-3.x cython pyinstaller spacy


【解决方案1】:

这可能会在 cython 0.28 中解决,看这里https://github.com/cython/cython/issues/1953

【讨论】:

  • 我想这不是您需要 Cython 0.28,而是您需要使用 Cython 0.28 构建的 NeuralCoref
  • @DavidW 正确。我只需要NeuralCoref。而Neural的要求是,spacy>=2.1.0 cython>=0.25 pytest
  • 如果你用 Cython 0.28 从源代码编译神经核呢?
  • 参见此处从源代码编译神经核:github.com/huggingface/…
  • 感谢@SofieVL。也试过了。不工作。
猜你喜欢
  • 2012-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-14
相关资源
最近更新 更多