2016-03-02 59 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

相关问题