打开cx_freeze构建的exe文件时出错

时间:2015-02-16 15:29:26

标签: python python-3.x matplotlib pyqt cx-freeze

我使用PyQt5,matplotlib,numpy,scipy,nmrglue编写了一个程序,并设法使用cx_freeze将其构建到exe文件中。

这是我的setup.py:

from cx_Freeze import setup, Executable

setup(name= 'NmrAnalysis',
      version = '1.0',
      description = 'Analysis System by iceorange',
      executables = [Executable('MainWindow.py')])

当我执行MainWindow.exe时,它说:

E:\PycharmProjects\NmrAnalysis\build\exe.win-amd64-3.4>MainWindow.exe > ../out.txt
Traceback (most recent call last):
  File "D:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
    exec(code, m.__dict__)
  File "MainWindow.py", line 5, in <module>
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "E:\PycharmProjects\NmrAnalysis\nmr_analysis.py", line 8, in <module>
    import nmrglue as ng
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "D:\Python34\lib\site-packages\nmrglue\__init__.py", line 1, in <module>
    from .fileio import *
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "D:\Python34\lib\site-packages\nmrglue\fileio\__init__.py", line 1, in <module>
    from . import bruker
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2284, in _handle_fromlist
  File "X:\Python34\lib\importlib\_bootstrap.py", line 321, in _call_with_frames_removed
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "D:\Python34\lib\site-packages\nmrglue\fileio\bruker.py", line 37, in <module>
    from ..process import proc_base
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "D:\Python34\lib\site-packages\nmrglue\process\__init__.py", line 1, in <module>
    from . import proc_base
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2284, in _handle_fromlist
  File "X:\Python34\lib\importlib\_bootstrap.py", line 321, in _call_with_frames_removed
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "D:\Python34\lib\site-packages\nmrglue\process\proc_base.py", line 11, in <module>
    import scipy.signal
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "D:\Python34\lib\site-packages\scipy\signal\__init__.py", line 264, in <module>
    from .bsplines import *
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "D:\Python34\lib\site-packages\scipy\signal\bsplines.py", line 4, in <module>
    import scipy.special
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "D:\Python34\lib\site-packages\scipy\special\__init__.py", line 586, in <module>
    from ._ufuncs import *
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "X:\Python34\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "X:\Python34\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "ExtensionLoader_scipy_special__ufuncs.py", line 22, in <module>
  File "ExtensionLoader_scipy_special__ufuncs.py", line 14, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.

当我在Dependency Walker中运行时,它说: enter image description here 如何解决这个问题呢? 非常感谢!

1 个答案:

答案 0 :(得分:2)

我终于成功了。

我在这里写了一个wiki笔记: https://github.com/lianxiangru/NMR-Analysis-UI/wiki/Notes

Py2exe也可以使用类似的程序。