使用pyinstaller构建python pylab/matplotlib exe [英] Building python pylab/matplotlib exe using pyinstaller

查看:112
本文介绍了使用pyinstaller构建python pylab/matplotlib exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在作为解释型python py程序运行时运行良好,并显示一个简单的饼图.

The following code runs fine and displays a simple pie chart when run as an interpreted python py program.

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

A month ago, I used pyinstaller to create a stand-alone exe and that worked great.

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

Recently, I decided to rebuild the exe. The pyinstaller build completes successfully without errors, but the generated exe does nothing when run. When I run it, it ends quickly without any errors and without displaying a pie chart. Something has changed since a month ago, but I can't figure out what. I've tried uninstalling python and all modules and reinstalling, but that made no difference.

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代码时遇到问题.

This is the pyinstaller command I am using to build the exe. This command works for other pyqt gui builds and their exe's work fine. I am only having a problem building pylab/matplotlib python code.

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

推荐答案

找到了解决方案.显然我的pyinstaller版本中存在一个错误.在pyinstaller网站上找到了该帖子: http://www.pyinstaller.org/ticket/651

Found the solution. Apparently there was a bug in the version of pyinstaller I had. Found this post on pyinstaller's site: http://www.pyinstaller.org/ticket/651

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

So I downloaded the latest pyinstaller and I can build an exe of my piechart python program again!

这篇关于使用pyinstaller构建python pylab/matplotlib exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆