使用PyInstaller使用PyQt4 + Matplotlib冻结Python应用程序

时间:2014-11-12 13:14:20

标签: python qt matplotlib pyinstaller

尝试"冻结"一个Python(v2.78)应用程序在Windows XP SP3下使用PyQt4(v4.10.4)和Matplotlib(v1.4.2),使用PyInstaller(v2.1),我遇到了一个恼人的问题。

在我的课程开始时,我有以下几行:

import matplotlib
matplotlib.use("Qt4Agg")
matplotlib.rcParams["backend.qt4"] = "PyQt4"
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

当我使用以下行运行PyInstaller时:

pyinstaller --noconsole --icon=app.ico App.py

将应用程序正确地冻结到" dist"文件夹,它运行没有任何麻烦。问题是,分发文件夹中包含了许多不需要的文件!通过这些"不需要的"文件,我指的是几个" wx"对我的应用程序显然无用的模块(因为它使用Qt而不是Wx用于UI)。如果我从dist文件夹手动删除这些文件,该应用程序仍然运行良好。

所以,我的一个大问题是:在使用PyInstaller冻结应用程序时如何摆脱这些不需要的文件?

我可以找到py2exe和cx_Freeze类似问题的几种可能的解决方案,但没有任何引用PyInstaller(这些是我的首选"编译器"因为它是唯一似乎是跨平台的在Windows和Linux下工作得非常好。)

提前感谢您提供的任何帮助!

编辑:此外,运行PyInstaller时,我收到一条丑陋的错误消息:

43592 INFO: Processing hook hook-matplotlib
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_webagg.py", li
ne 30, in <module>
    raise RuntimeError("The WebAgg backend requires Tornado.")
RuntimeError: The WebAgg backend requires Tornado.

但当然我没有使用任何WebAgg后端(并且不知道到底是什么&#34; Tornado&#34;!)。

在冻结过程结束时,我收到了警告:

265046 WARNING: lib not found: gdiplus.dll dependency of C:\Python27\lib\site-pa
ckages\wx-2.8-msw-unicode\wx\wxmsw28u_core_vc.dll

我也希望在冻结过程中消除这两个消息(当我解决掉掉不需要的后端的问题时,我认为我将会解决这个问题)!

&#34;

0 个答案:

没有答案