2016-03-02 96 views
1

我使用Pyinstaller(花了很長時間與py2exe後)將我的REAL.py文件轉換爲.exe文件。我使用Anaconda來製作在我的電腦上完美運行的.py文件。但是,當我製作.exe文件時,它不顯示錯誤,並在dist \ REAL文件夾中創建應用程序。但是當我運行.exe文件時,控制檯會立即打開並關閉。Pykinler與Tkinter Matplotlib numpy scipy

它應該理想地顯示一個GUI窗口並採取輸入並用它們來繪製圖。它在我運行REAL.py文件時這樣做。我使用的是與蟒蛇一起出現的Tkinter,Matplotlib,numpy,scipy。

編輯:我試圖運行簡單的代碼檢查與matplotlib的相容性:

進口matplotlib.pyplot作爲PLT

plt.plot([1,2,3,4])

plt.ylabel( '一些數字')

plt.show()

同樣的問題與此仍然存在。打開控制檯窗口,然後關閉,但沒有發佈任何情節。

+0

我有一個類似的問題。你可能想嘗試的一件事就是使用'--debug'標誌作爲pyinstaller的參數 - 它可以幫助你識別具體的失敗是什麼。 – user888379

回答

0

我在py2exe中找到了解決方案。以下是與Tkinter的Matplotlib numpy的SciPy的進口工作的setup.py文件:

from distutils.core import setup 
import py2exe 

from distutils.filelist import findall 
import matplotlib 

opts = {"py2exe": { 
    "packages" : ['matplotlib'], 
    "includes": ['scipy', 'scipy.integrate', 'scipy.special.*','scipy.linalg.*'], 
     'dll_excludes': ['libgdk-win32-2.0-0.dll', 
          'libgobject-2.0-0.dll', 
      'libgdk_pixbuf-2.0-0.dll'] 
        } 
      } 

setup(
     windows = [{'script': "with_GUI.py"}], zipfile = None, 
     options= opts, 
     data_files = matplotlib.get_py2exe_datafiles() 
    ) 

但是,這給了我一些錯誤說,有兩個文件版本衝突。所以我改變了兩個文件即。 dist/tcl/tcl8.5/init.tcl(行19)和dist/tcl/tk8.5/tk.tcl(行18)。在我的情況下,我將版本從8.5.15更改爲8.5.18。通過查看錯誤日誌中錯誤指定的路徑,我找到了這兩個文件的位置。然後.exe工作得很好。

我希望這會有所幫助。

0

嘗試在調用pyinstaller時使用--hidden-import = matplotlib。例如,在命令提示符下鍵入:

Pyinstaller --hidden進口= matplotlib your_filename_here.py

,你可以嘗試給它用Tkinter的一個鏡頭在那裏。

Pyinstaller --hidden進口= matplotlib --hidden進口= Tkinter的your_filename_here.py