2013-12-13 63 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名單中有大約六件事情。