Pyinstaller .exe的MatplotlibDeprecation警告

问题描述 投票:2回答:1

我遇到警告,该警告仅在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.2Pyinstaller 3.5Matplotlib 3.1.1

python-3.x matplotlib pyinstaller
1个回答
0
投票

找到(部分)解决此问题的here the pyinstaller issue

对于matplotlib> = 3.1显然已弃用警告。但是,PyInstaller当前依赖于此环境变量MATPLOTLIBDATA,原因尚不清楚。在pyi_rth_mpldata.py中找到引起警告的代码段。不幸的是,仅在本地取消注释该行(site-packages / PyInstaller / loader / rthooks / rpyi_rth_mpldata.py)

os.environ["MATPLOTLIBDATA"] = os.path.join(sys._MEIPASS, "mpl-data")

这不是一种选择,导致我的PyInstaller软件包崩溃。

我目前看到以下选项:

  1. 降级matplotlib到v3.0(pip install 'matplotlib==3.0.3'
  2. 本地禁用弃用警告在matplotlib(matplotlib/__init__.py:625)中
  3. wait或支持pyinstaller团队查找补丁...

选项1.为我(部分)工作,希望你也很幸运。选项2是最简单的,不应有任何副作用。

© www.soinside.com 2019 - 2024. All rights reserved.