小编pau*_*gam的帖子

pyinstaller:使用 matplotlib 构建一个 python exe

我一直在尝试复制这篇文章的例子,用 pyinstaller 生成一个可执行文件,但没有成功。我在Linux操作系统上。

我尝试构建的 exe 基于此代码(之后是 test.py)

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()
Run Code Online (Sandbox Code Playgroud)

要创建我运行的可执行文件

pyinstaller --onefile test.py
Run Code Online (Sandbox Code Playgroud)

我尝试了 3.0 版(pip 安装中的官方版本)和 pyinstaller 的 3.1.dev 版。两者都编译但是当我运行可执行文件时我得到了

./test 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", …
Run Code Online (Sandbox Code Playgroud)

python matplotlib pyinstaller

5
推荐指数
1
解决办法
8008
查看次数

标签 统计

matplotlib ×1

pyinstaller ×1

python ×1