【发布时间】:2022-01-07 14:07:47
【问题描述】:
我想使用 pyinstaller onefile 将 python 文件编译为独立的 .exe 程序。运行python文件,一切正常,但运行.exe文件,却抛出异常
ModuleNotFoundError: 没有名为“matplotlib.backends.backend_svg”的模块
我正在使用schemdraw, 并且 schemdraw 使用 matplotlib。
因为我不希望 matplotlib 在每次导出 svg 时都打开一个窗口,所以我将后端“Agg”与 matplotlib 一起使用。
import matplotlib.backends.backend_tkagg
import matplotlib
matplotlib.use('Agg')
- 我当然试过重新安装matplotlib
- 使用而不是 pyinstaller
--onefile <file>pyinstaller <file> - 我尝试将
import matplotlib.backends.backend_tkagg放在import matplotlip上 - 升级matplotlib
pip install matplotlib --upgrade --user基本上this post。但由于这不完全是我的问题,而且都没有奏效,所以我在这里问
提前致谢
【问题讨论】:
标签: python python-3.x matplotlib pyinstaller