scipy.optimize._trlib._trlib.array' 使用 pyinstaller 时没有属性 '__reduce_cython__'
Posted
技术标签:
【中文标题】scipy.optimize._trlib._trlib.array\' 使用 pyinstaller 时没有属性 \'__reduce_cython__\'【英文标题】:scipy.optimize._trlib._trlib.array' has no attribute '__reduce_cython__' when using pyinstallerscipy.optimize._trlib._trlib.array' 使用 pyinstaller 时没有属性 '__reduce_cython__' 【发布时间】:2017-12-20 11:03:50 【问题描述】:我想将我的项目制作成exe文件,但是,当我在pyinstaller处理后打开main.exe
时,CMD出现错误。
我的环境是Win10,python3.6.2,使用PyQt5作为GUI,scapy3k嗅探数据包。
或者有其他方法可以将我的项目变成 exe?
Traceback (most recent call last):
File "main.py", line 103, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scapy\all.py", line 16, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scapy\arch\__init__.py", line 25, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "networkx\__init__.py", line 93, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "networkx\linalg\__init__.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "networkx\linalg\algebraicconnectivity.py", line 105, in <module>
File "networkx\linalg\algebraicconnectivity.py", line 122, in _LUSolver
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\sparse\linalg\__init__.py", line 118, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\sparse\linalg\matfuncs.py", line 19, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\special\__init__.py", line 648, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\special\_ellip_harm.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
File "_ellip_harm_2.pyx", line 7, in init scipy.special._ellip_harm_2
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\integrate\__init__.py", line 93, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\integrate\_bvp.py", line 11, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\optimize\__init__.py", line 241, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\optimize\_minimize.py", line 28, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\optimize\_trustregion_krylov.py", line 2, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "scipy\optimize\_trlib\__init__.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
File "d:\python36\lib\site-packages\pyinstaller-3.4.dev0+ab8fd9753-py3.6.egg\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
File "stringsource", line 103, in init scipy.optimize._trlib._trlib
AttributeError: type object 'scipy.optimize._trlib._trlib.array' has no attribute '__reduce_cython__'
我的程序的源代码在这里: The Github link to my program
怎么了?
【问题讨论】:
【参考方案1】:抛出一个长代码和你的整个 github 目录并不容易修复错误。见:https://github.com/cython/cython/issues/1953
我使用 cython 和 pyinstaller 没有任何问题。
有 cxfreeze 但我不推荐它。它是 pyinstaller 的较旧、错误的版本,没有 pyupdater 的更新功能。
【讨论】:
什么意思?你成功把我的项目转成exe了?恐怕更新 lxml 后我仍然有同样的问题。并且 cxfreeze 在我的计算机上也无法正常工作。 @user6456568 不知道我能提供什么帮助。这是很多问题。我也从未说过你的项目,但我已经让 cython 与 pyinstaller 一起工作。祝你好运。 在我的情况下,我遇到了同样的错误(但使用 scipy),@user9045698 将我指向正确的线程:更新 scipy(我假设使用更新的 cython)后我不再收到错误.【参考方案2】:在主要的python代码中,键入以下代码:
from scipy import optimize
然后运行pyinstaller生成exe文件。
【讨论】:
我不是这方面的专家,但到目前为止我看到的是 OP 在导入您建议的from scipy import optimize
时可以使用的一堆函数。 OP 不应该添加一些附加行来做某事,还是只需要编译器/pyinstaller?此外:欢迎来到 SO。感谢您发布答案。请阅读有关how to ask a good answer 的信息。尽情享受吧 ;-)以上是关于scipy.optimize._trlib._trlib.array' 使用 pyinstaller 时没有属性 '__reduce_cython__'的主要内容,如果未能解决你的问题,请参考以下文章
当 scipy.optimize.minimize 可能用于相同的事情时,为啥 scipy.optimize.least_squares 存在?
使用 scipy.optimize.minimize 提前停止损失函数
scipy.optimize.leastsq 用 NaN 调用目标函数