使用pyinstaller时出现错误“没有属性'reduce_cython”

时间:2018-07-19 08:23:17

标签: python tensorflow pyinstaller

我使用pyinstaller将我的modeltest.py文件转换为exe。 执行它时,我得到了

AttributeError: type object 'scipy.interpolate.interpnd.array' has no attribute '__reduce_cython__'

在参考Internet上的解决方案后,我正在使用scipy 1.1.0Cython 0.28.3。 我尝试更新Cython,但是没有运气。

是否有人建议解决将.py转换为exe的这种或更好的方法? 我已经在新的python3.5环境中尝试过py2exe,推荐用于tensorflow。但是经过一个小时的学习,每次我在cmd中输入python setup.py py2exe时,它只会返回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

更新:   我将Cythonpandas的版本更改为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,那么我可以成功运行.exe文件)< / p>

下面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__

更新: 我将pyinstaller生成的_pywrap_tensorflow_internal.pyd文件夹中dist\project_name\的文件名更改为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__'

更新: 我通过使用最新开发版本的pyinstaller解决了这个问题。当我尝试在github上的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

即使如此,我仍然需要手动将一些文件添加到dist\<porject_name>文件夹中,包括来自 Keras``Keras_applications``Keras_preprocessing``tensorflow

和DLL文件来自 C:\Users\Administrator\AppData\Local\Programs\Python\Python35\Lib\site-packages

所以我将继续研究找出如何将所有文件打包到一个.exe文件中。

1 个答案:

答案 0 :(得分:2)

我通过以下步骤解决问题:

首先:使用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的兼容版本。 将_pywrap_tensorflow_internal.pyd文件夹中包含的文件dist\<project_name>重命名为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>