使用 pyinstaller 时出现错误“没有属性‘reduce_cython”
When using pyinstaller got Error " has no attribute 'reduce_cython"
我使用 pyinstaller 将我的 modeltest.py
文件转换为 exe。
在执行它时我得到了
AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'
参考了网上的解决方法,我现在用的是scipy 1.1.0
和Cython 0.28.3
。
我试过更新 Cython
但没有成功。
有什么解决此问题的建议或将 .py
转换为 exe 的更好方法吗?
我在一个新的环境中尝试了 py2exe
python3.5,推荐用于 tensorflow。但是经过一个小时的学习,每次我在cmd中输入python setup.py py2exe
它只是returns running py2exe
并且没有更多的反应。
我尝试用 cx_freeze
冻结它以获得更多调试输出,但没有任何结果。完全是空的,没有错误,没有日志,就像我什么都没输入一样。
下面来自 pyinstall 的完整日志:
Using TensorFlow backend.
Traceback (most recent call last):
File "testmodel.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\__init__.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\datasets\__init__.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\datasets\imdb.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\preprocessing\__init__.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\preprocessing\image.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras_preprocessing\image.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\__init__.py", line 161, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\filters.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\_ni_docstrings.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\misc\__init__.py", line 68, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\interpolate\__init__.py", line 175, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\interpolate\interpolate.py", line 32, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
File "stringsource", line 104, in init scipy.interpolate.interpnd
AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'
[9828] Failed to execute script testmodel
更新:
我将 Cython
和 pandas
的版本更改为 Mr.J 的列表:
Cython==0.27.3
h5py==2.8.0
Keras==2.2.0
Keras-Applications==1.0.2
Keras-Preprocessing==1.0.1
numpy==1.14.5
pandas==0.20.3
PyInstaller==3.3.1
pypiwin32==223
python-dateutil==2.7.3
pytz==2018.5
pywin32==223
PyYAML==3.13
scipy==1.1.0
six==1.11.0
tensorboard==1.9.0
tensorflow-gpu==1.9.0
UNKNOWN==0.0.0
错误 no attribute '__reduce_cython__'
已消失,
出现新错误:
Using TensorFlow backend.
Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ImportError: Module use of python36.dll conflicts with this version of Python.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testmodel.py", line 5, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\__init__.py", line 3, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\utils\__init__.py", line 6, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\utils\conv_utils.py", line 9, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\backend\__init__.py", line 87, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\__init__.py", line 22, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\__init__.py", line 49, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
ImportError: Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ImportError: Module use of python36.dll conflicts with this version of Python.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
[8216] Failed to execute script testmodel
更新:我在 win7 上删除了 python3.6,它仍然无法正常工作。
记录如下:
Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testmodel.py", line 5, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\__init__.py", line 3, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\utils\__init__.py", line 6, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\utils\conv_utils.py", line 9, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\backend\__init__.py", line 87, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\__init__.py", line 22, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\__init__.py", line 49, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
ImportError: Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
[4840] Failed to execute script testmodel
更新:
我发现了与 Anaconda3\envs\<my_envs_name>\Lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py
相关的问题
.并且由于我代码中的这一行,它尝试执行该文件:from keras.model import load_model
(如果我将这一行转为 Comment with #
,那么我可以成功 运行 .exe
文件 )
下面pywrap_tensorflow_internal.py
中的片段:
(我插入 print(error)
进行调试,我认为这个函数导致了问题)
from sys import version_info
if version_info >= (2, 7, 0):
def swig_import_helper():
print('Error!')
import importlib
pkg = __name__.rpartition('.')[0]
mname = '.'.join((pkg, '_pywrap_tensorflow_internal')).lstrip('.')
return importlib.import_module(mname)
_pywrap_tensorflow_internal = swig_import_helper()
del swig_import_helper
elif version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
except ImportError:
import _pywrap_tensorflow_internal
return _pywrap_tensorflow_internal
if fp is not None:
try:
_mod = imp.lo
ad_module('_pywrap_tensorflow_internal', fp, pathname, description)
finally:
fp.close()
return _mod
_pywrap_tensorflow_internal = swig_import_helper()
del swig_import_helper
else:
import _pywrap_tensorflow_internal
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
try:
import builtins as __builtin__
except ImportError:
import __builtin__
更新:
我将 dist\project_name\
文件夹中的 _pywrap_tensorflow_internal.pyd
的文件名更改为 pyinstaller 生成的 tensorflow.python._pywrap_tensorflow_internal.pyd
.
又回到了最开始的问题:
AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'
日志之间只有一点点差异。
日志:
Traceback (most recent call last):
File "testmodel.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\__init__.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\datasets\__init__.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\datasets\imdb.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\preprocessing\__init__.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\preprocessing\image.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras_preprocessing\image.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\__init__.py", line 161, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\filters.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\_ni_docstrings.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\misc\__init__.py", line 68, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\interpolate\__init__.py", line 175, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\interpolate\interpolate.py", line 32, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
File "stringsource", line 104, in init scipy.interpolate.interpnd
AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'
更新:
当我尝试在 github 的 pyinstaller 页面上打开新问题时,我通过使用 pyinstaller.I 的最新开发版本找到了这些方向:
If you have problems to get your application running, please first
* try the latest development version, using the following command:
shell
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
即便如此,我还是需要手动添加一些文件到dist\<porject_name>
文件夹,包括来自Keras``Keras_applications``Keras_preprocessing``tensorflow
的文件夹
C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages
和来自的DLL文件
C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages\scipy\extra-dll
所以我会继续研究如何将所有文件打包成一个.exe文件。
我按照以下步骤解决:
首先:使用最新开发版的pyinstaller。
If you have problems to get your application running, please first
* try the latest development version, using the following command:
shell
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
确保没有其他 python interpreter
干扰您的系统。
并找到 python pandas cython scipy
的兼容版本。
将 dist\<project_name>
文件夹中包含的文件 _pywrap_tensorflow_internal.pyd
重命名为 tensorflow.python._pywrap_tensorflow_internal.pyd
.
然后复制
tensorflow
来自 C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages
的文件夹
和来自 C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages\scipy\extra-dll
的 DLL 文件
至 dist\<project_name>
我使用 pyinstaller 将我的 modeltest.py
文件转换为 exe。
在执行它时我得到了
AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'
参考了网上的解决方法,我现在用的是scipy 1.1.0
和Cython 0.28.3
。
我试过更新 Cython
但没有成功。
有什么解决此问题的建议或将 .py
转换为 exe 的更好方法吗?
我在一个新的环境中尝试了 py2exe
python3.5,推荐用于 tensorflow。但是经过一个小时的学习,每次我在cmd中输入python setup.py py2exe
它只是returns running py2exe
并且没有更多的反应。
我尝试用 cx_freeze
冻结它以获得更多调试输出,但没有任何结果。完全是空的,没有错误,没有日志,就像我什么都没输入一样。
下面来自 pyinstall 的完整日志:
Using TensorFlow backend.
Traceback (most recent call last):
File "testmodel.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\__init__.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\datasets\__init__.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\datasets\imdb.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\preprocessing\__init__.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\preprocessing\image.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras_preprocessing\image.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\__init__.py", line 161, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\filters.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\_ni_docstrings.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\misc\__init__.py", line 68, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\interpolate\__init__.py", line 175, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\interpolate\interpolate.py", line 32, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "c:\programdata\anaconda3\envs\tfgpu\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
File "stringsource", line 104, in init scipy.interpolate.interpnd
AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'
[9828] Failed to execute script testmodel
更新:
我将 Cython
和 pandas
的版本更改为 Mr.J 的列表:
Cython==0.27.3
h5py==2.8.0
Keras==2.2.0
Keras-Applications==1.0.2
Keras-Preprocessing==1.0.1
numpy==1.14.5
pandas==0.20.3
PyInstaller==3.3.1
pypiwin32==223
python-dateutil==2.7.3
pytz==2018.5
pywin32==223
PyYAML==3.13
scipy==1.1.0
six==1.11.0
tensorboard==1.9.0
tensorflow-gpu==1.9.0
UNKNOWN==0.0.0
错误 no attribute '__reduce_cython__'
已消失,
出现新错误:
Using TensorFlow backend.
Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ImportError: Module use of python36.dll conflicts with this version of Python.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testmodel.py", line 5, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\__init__.py", line 3, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\utils\__init__.py", line 6, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\utils\conv_utils.py", line 9, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\backend\__init__.py", line 87, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\__init__.py", line 22, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\__init__.py", line 49, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
ImportError: Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
File "c:\programdata\anaconda3\envs\tensorflow\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ImportError: Module use of python36.dll conflicts with this version of Python.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
[8216] Failed to execute script testmodel
更新:我在 win7 上删除了 python3.6,它仍然无法正常工作。
记录如下:
Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testmodel.py", line 5, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\__init__.py", line 3, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\utils\__init__.py", line 6, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\utils\conv_utils.py", line 9, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\backend\__init__.py", line 87, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\__init__.py", line 22, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\__init__.py", line 49, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
ImportError: Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
[4840] Failed to execute script testmodel
更新:
我发现了与 Anaconda3\envs\<my_envs_name>\Lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py
相关的问题
.并且由于我代码中的这一行,它尝试执行该文件:from keras.model import load_model
(如果我将这一行转为 Comment with #
,那么我可以成功 运行 .exe
文件 )
下面pywrap_tensorflow_internal.py
中的片段:
(我插入 print(error)
进行调试,我认为这个函数导致了问题)
from sys import version_info
if version_info >= (2, 7, 0):
def swig_import_helper():
print('Error!')
import importlib
pkg = __name__.rpartition('.')[0]
mname = '.'.join((pkg, '_pywrap_tensorflow_internal')).lstrip('.')
return importlib.import_module(mname)
_pywrap_tensorflow_internal = swig_import_helper()
del swig_import_helper
elif version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
except ImportError:
import _pywrap_tensorflow_internal
return _pywrap_tensorflow_internal
if fp is not None:
try:
_mod = imp.lo
ad_module('_pywrap_tensorflow_internal', fp, pathname, description)
finally:
fp.close()
return _mod
_pywrap_tensorflow_internal = swig_import_helper()
del swig_import_helper
else:
import _pywrap_tensorflow_internal
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
try:
import builtins as __builtin__
except ImportError:
import __builtin__
更新:
我将 dist\project_name\
文件夹中的 _pywrap_tensorflow_internal.pyd
的文件名更改为 pyinstaller 生成的 tensorflow.python._pywrap_tensorflow_internal.pyd
.
又回到了最开始的问题:
AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'
日志之间只有一点点差异。
日志:
Traceback (most recent call last):
File "testmodel.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\__init__.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\datasets\__init__.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\datasets\imdb.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\preprocessing\__init__.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras\preprocessing\image.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\keras_preprocessing\image.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\__init__.py", line 161, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\filters.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\ndimage\_ni_docstrings.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\misc\__init__.py", line 68, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\interpolate\__init__.py", line 175, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\interpolate\interpolate.py", line 32, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "c:\programdata\anaconda3\envs\pyinstaller\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
File "stringsource", line 104, in init scipy.interpolate.interpnd
AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'
更新: 当我尝试在 github 的 pyinstaller 页面上打开新问题时,我通过使用 pyinstaller.I 的最新开发版本找到了这些方向:
If you have problems to get your application running, please first
* try the latest development version, using the following command:
shell
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
即便如此,我还是需要手动添加一些文件到dist\<porject_name>
文件夹,包括来自Keras``Keras_applications``Keras_preprocessing``tensorflow
的文件夹
C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages
和来自的DLL文件
C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages\scipy\extra-dll
所以我会继续研究如何将所有文件打包成一个.exe文件。
我按照以下步骤解决:
首先:使用最新开发版的pyinstaller。
If you have problems to get your application running, please first
* try the latest development version, using the following command:
shell
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
确保没有其他 python interpreter
干扰您的系统。
并找到 python pandas cython scipy
的兼容版本。
将 dist\<project_name>
文件夹中包含的文件 _pywrap_tensorflow_internal.pyd
重命名为 tensorflow.python._pywrap_tensorflow_internal.pyd
.
然后复制
tensorflow
来自 C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages
和来自 C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages\scipy\extra-dll
的 DLL 文件
至 dist\<project_name>