使用pyinstaller构建python pylab / matplotlib exe

时间:2013-06-13 19:12:42

标签: python matplotlib pyinstaller

以下代码运行正常,并在作为解释的python py程序运行时显示一个简单的饼图。

一个月前,我使用pyinstaller创建了一个独立的exe,效果很好。

最近,我决定重建exe。 pyinstaller构建成功完成且没有错误,但生成的exe在运行时不执行任何操作。当我运行它时,它会很快结束,没有任何错误,也没有显示饼图。自一个月前以来发生了一些变化,但我无法弄清楚是什么。我已经尝试卸载python和所有模块并重新安装,但这没有任何区别。

from pylab import *
from matplotlib import pyplot as plt

figure(1, figsize=(6,6))
ax = axes([0.1, 0.1, 0.8, 0.8])

labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
fracs = [15, 30, 45, 10]
explode=(0, 0.05, 0, 0)

pie(fracs, explode=explode, labels=labels,
                autopct='%1.1f%%', startangle=90)

title('Pie Chart Example', bbox={'facecolor':'0.8', 'pad':5})

show()

这是我用来构建exe的pyinstaller命令。此命令适用于其他pyqt gui构建及其exe的工作正常。我只是在构建pylab / matplotlib python代码时遇到了问题。

c:/python27/python.exe c:/pyinstaller/pyinstaller.py --noconfirm --noconsole --onefile --icon=pie.ico pie.py

1 个答案:

答案 0 :(得分:1)

找到解决方案。显然我的pyinstaller版本中有一个错误。在pyinstaller的网站上发现了这篇文章:http://www.pyinstaller.org/ticket/651

所以我下载了最新的pyinstaller,我可以再次构建我的piechart python程序的exe!

相关问题