gpt4 book ai didi

python - 使用 pyinstaller 构建 python pylab/matplotlib exe

转载 作者:太空宇宙 更新时间:2023-11-04 06:13:49 25 4
gpt4 key购买 nike

以下代码运行良好,并在作为解释型 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

最佳答案

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

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

关于python - 使用 pyinstaller 构建 python pylab/matplotlib exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17095180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com