使用py2exe创建的exe不起作用并返回包含错误的logfile

时间:2013-11-24 00:35:44

标签: python numpy scipy py2exe logfile-analysis

这是我的第一篇文章,所以对我很轻松。我的问题与此类似,但我无法使其工作,尽管我真的尝试过: “py2exe with enthought and pandas”。

单独安装了两个版本的python(x84-64,x32)和库后,我继续使用py2exe生成python脚本的可执行文件。 我不得不下载丢失的DLL文件:msvcp90.dll,libiomp5md.dll,libifcoremd.dll,libmmd.dll。
我创建的exe文件返回错误并生成了一个日志文件 - x32和x64 python&库不同。

对于32位python&库,我得到了以下日志文​​件(根据我安装的numpy库不同而不同:http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

对于numpy-1.8.0-win32-superpack-python2.7,我收到了多个以下信息:

File "gui.py", line 7, in <module>
File "pyqtgraph\__init__.pyc", line 177, in <module>
File "pyqtgraph\__init__.pyc", line 167, in importAll
File "pyqtgraph\__init__.pyc", line 159, in importModules
Traceback (most recent call last):
File "gua.py", line 7, in <module>
File "pyqtgraph\__init__.pyc", line 180, in <module>
File "pyqtgraph\imageview\__init__.pyc", line 6, in <module>
File "pyqtgraph\imageview\ImageView.pyc", line 20, in <module>
File "pyqtgraph\imageview\ImageViewTemplate_pyqt.pyc", line 159, in <module>
File "pyqtgraph\widgets\PlotWidget.pyc", line 10, in <module>
File "pyqtgraph\graphicsItems\PlotItem\__init__.pyc", line 1, in <module>
File "pyqtgraph\graphicsItems\PlotItem\PlotItem.pyc", line 32, in <module>
File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
File "scipy\stats\__init__.pyc", line 324, in <module>
File "scipy\stats\stats.pyc", line 242, in <module>
File "scipy\special\__init__.pyc", line 531, in <module>
File "scipy\special\_ufuncs.pyc", line 12, in <module>
File "scipy\special\_ufuncs.pyc", line 10, in __load
File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:19840)
ImportError: No module named _ufuncs_cxx

对于numpy-MKL- 1.8.0.win32-py 2.7:

Traceback (most recent call last):
File "gui.py", line 2, in <module>
File "numpy\__init__.pyc", line 154, in <module>
File "numpy\add_newdocs.pyc", line 9, in <module>
File "numpy\lib\__init__.pyc", line 13, in <module>
File "numpy\lib\polynomial.pyc", line 17, in <module>
File "numpy\linalg\__init__.pyc", line 48, in <module>
File "numpy\linalg\linalg.pyc", line 23, in <module>
File "numpy\linalg\lapack_lite.pyc", line 12, in <module>
File "numpy\linalg\lapack_lite.pyc", line 10, in __load
ImportError: DLL load failed: %1 is not a valid Win32 application.

对于我收到的numpy-MKL-1.7.2rc1.win32-py2.7,但是成倍增加。

对于64位python&amp;库我得到了以下内容,与scipy和numpy版本无关:

File "gui.py", line 7, in <module>
File "pyqtgraph\__init__.pyc", line 177, in <module>
File "pyqtgraph\__init__.pyc", line 167, in importAll
File "pyqtgraph\__init__.pyc", line 159, in importModules
Traceback (most recent call last):
File "pyqtgraph\__init__.pyc", line 155, in importModules
File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
File "scipy\stats\__init__.pyc", line 324, in <module>
File "scipy\stats\stats.pyc", line 242, in <module>
File "scipy\special\__init__.pyc", line 531, in <module>
File "scipy\special\_ufuncs.pyc", line 12, in <module>
File "scipy\special\_ufuncs.pyc", line 10, in __load
File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:19992)
ImportError: No module named _ufuncs_cxx

我在.. \ build \ bdist.win-amd64 \ winexe \ collect-2.7 \ scipy \ special中有一些ufuncs文件,但我不确定它是如何工作的或应该有效。

那么我该怎么做才能使这些.exe工作?最好是与64位python一起使用的,因为通过在32位python中使用SciTe运行代码来打开程序需要很长时间并且存在内存过载。

编辑:

从setup.py中删除import numpy, pyqtgraph, scipy后,我收到以下日志文​​件,其中包含错误:

File "gui.py", line 7, in <module>
File "pyqtgraph\__init__.pyc", line 177, in <module>
File "pyqtgraph\__init__.pyc", line 167, in importAll
File "pyqtgraph\__init__.pyc", line 159, in importModules
Traceback (most recent call last):
File "pyqtgraph\__init__.pyc", line 155, in importModules
File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 2, in <module>
File "scipy\fftpack\__init__.pyc", line 97, in <module>
File "scipy\fftpack\basic.pyc", line 12, in <module>
File "scipy\fftpack\_fftpack.pyc", line 12, in <module>
File "scipy\fftpack\_fftpack.pyc", line 10, in __load
ImportError: DLL load failed: %1 is not a valid Win32 application.

3 个答案:

答案 0 :(得分:12)

我使用PyInstaller比Py2exe更成功。在PyInstaller中,通过显式添加引用来解决问题:

pyinstaller myscript.py --hidden-import=scipy.special._ufuncs_cxx

PyInstaller还负责matplotlib imbroglio和Visual Studio DLL。

答案 1 :(得分:1)

来自distutils.core导入设置

导入py2exe

设置(控制台= [ 'hello.py'])

编辑:此处不包含任何其他库/模块

下一步在cmd:

python hello.py py2exe

答案 2 :(得分:1)

在使用py2exe

创建.exe文件时,我收到了相同的错误消息
File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:22830)

通过scipy.special._ufuncs_cxx添加到setup.py中的includes 选项解决了问题。 这就是我所拥有的。

from distutils.core import setup
import py2exe
import numpy

setup(
    console=['hello.py'],
    options={
        'py2exe': {
            r'includes': [r'scipy.sparse.csgraph._validation',
                          r'scipy.special._ufuncs_cxx']
        }
    }
)

请注意,它包含一些其他设置,以防止出现与numpy / scipy相关的错误。

  • import numpy
  • 包含基于this answer
  • scipy.sparse.csgraph._validation