2013-12-13 37 views
0

我创建了我的第一个Python工作程序,并将它在PyCharm中运行。使用Cx_freeze或PyInstaller不能(.exe)我的300行程序。 (Matplotlib/Scipy)

该程序有一个GUI,它基本上弹出一个窗口,有一个目录树,因此用户可以选择一个jpg文件,然后二进制化图像,然后让用户用滑块选择二进制阈值。它还显示两个其他图像,我执行图像转换。

因此,我的问题是我无法将其构建到.exe中。我试过Py2Exe,PyInstaller和CX_freeze。我试图在Pyinstaller中构建自己的.spec文件,但都没有成功。

我正在运行2.7.6。我最初安装了64位Python,因此我卸载了Python相关的所有内容,并安装了32位Python。

最初当我使用pyinstaller我只想得到导入错误:%1不是有效的Win32应用程序,然而,由于建设的.spec文件,现在我得到实际的错误。我尝试过使用钩子(hiddenimports = [“wx”,“scipy”,“skimage”,“matplotlib”,“numpy”])以确保包含所有正确的文件,但仍然没有运气。

是我收到现在的主要错误是:文件 “_ufuncs.pyx”,1号线,在初始化scipy.special._ufuncs(SciPy的\ special_ufuncs.c:19992)导入错误:没有模块名为_ufuncs_cxx

我还在下面创建了一个较小的代码,它弹出一个带有绘图的Wx窗口,但我在那里收到同样的错误。

就像我刚才提到的,我是Python的新手,我做了大量的阅读并且一直没有弄清楚这一点。我花了大概10-20个小时试图让它正确编译。

下面不是我的实际程序,而是一个使用wxPython和MatPlotLib的小片段,它产生了相同的错误

这是示例代码:

​​

这是我收到的错误:

Traceback (most recent call last): 
    File "<string>", line 11, in <module> 
    File "c:\python27_32bit\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstalle\loader\pyi_importers.py", line 270, in 
load_module 
    exec(bytecode, module.__dict__) 
    File "C:\users\iolvera\PycharmProjects\EL and Grayscale Analyzer\build\compilertest\out00-PYZ.pyz\scipy.interpolate",line 156, in <module> 
    File "c:\python27_32bit\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 270, in load_module 
    exec(bytecode, module.__dict__) 
    File "C:\users\iolvera\PycharmProjects\EL and Grayscale Analyzer\build\compilertest\out00-PYZ.pyz\scipy.interpolate.interpolate", line 12, in <module> 
    File "c:\python27_32bit\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 270, in load_module 
    exec(bytecode, module.__dict__) 
    File "C:\users\iolvera\PycharmProjects\EL and Grayscale Analyzer\build\compilertest\out00-PYZ.pyz\scipy.special", line 531, in <module> 
    File "c:\python27_32bit\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 409, in load_module 
    module = imp.load_module(fullname, fp, filename, self._c_ext_tuple) 
    File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:19992) 
ImportError: No module named _ufuncs_cxx 

我的Python路径是正确的C:\ Python27_32bit \我也有\ LIB \ site-packages \和\ DLL包含正确。

就像我提到的,这两个程序在PyCharm中都能正确运行。

任何帮助将不胜感激。

谢谢!

+0

问题出现在numpy的c-extensions。希望这点能让你朝着正确的方向前进。 – tacaswell

回答

1

我有这个问题,我通过专门告诉它包含有问题的模块将其固定在py2exe中。所以,在setup.py

includes = ['scipy.special._ufuncs_cxx'] 

setup(..., 
     options={"py2exe":{"includes":includes}} 
    ) 

我过这种情况与一对夫妇的其他SciPy的模块,也因此我includes名单中有大约六件事情。