我遇到了一个警告,该警告仅在运行 pyinstaller 可执行文件时出现。
...appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py:627: MatplotlibDeprecationWarning:
The MATPLOTLIBDATA environment variable was deprecated in Matplotlib 3.1 and will be removed in 3.3.
exec(bytecode, module.__dict__)
我已经尝试了这里的所有建议:Python/matplotlib : getting rid of matplotlib.mpl warning
我也试过这个,最终结果没有任何变化:
Pyinstaller exe hide warning messages
最终可执行文件中出现的 MatplotlibDeprecation 警告没有任何更改。在 Pycharm 等 IDE 中运行代码时,基线不存在警告。
使用:
python 3.7.2
pyinstaller 3.5
Matplotlib 3.1.1
最佳答案
查找 here the pyinstaller issue这(部分)解决了这个问题。
已为 matplotlib >=3.1 引入了弃用警告。因此,环境变量 MATPLOTLIBDATA
在 future 的版本中, Pandas 将不再使用。但是,由于我不太清楚的原因,PyInstaller 目前依赖于这个变量。
导致警告的代码段在 pyi_rth_mpldata.py 中找到:
os.environ["MATPLOTLIBDATA"] = os.path.join(sys._MEIPASS, "mpl-data")
不幸的是,简单地在本地取消注释该行 (site-packages/PyInstaller/loader/rthooks/rpyi_rth_mpldata.py) 不是一个选项,导致我的 PyInstaller 包崩溃。我目前看到以下选项:
pip install 'matplotlib==3.0.3'
) matplotlib/__init__.py:625
) 选项 1. 为我工作,希望你也很幸运。选项 2. 和 3. 是最简单的,应该没有任何副作用。
关于python-3.x - MatplotlibDeprecationWarning 与 Pyinstaller .exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57517371/