Adr*_*ian 4 python matplotlib pyinstaller
我使用 pyinstaller 从 python 文件生成了一个可执行文件。该程序以它应该如何工作的方式工作,但有一条警告消息出现在我想隐藏的窗口中。
当 python 文件在 IDE 中运行时,以下行会抑制所有警告消息。
warnings.filterwarnings('ignore')
Run Code Online (Sandbox Code Playgroud)
但是在可执行文件的窗口中,显示了这个警告:
\venv\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__)
Run Code Online (Sandbox Code Playgroud)
如果您打算使用自定义的spec构建文件,您只需将以下行添加到您的spec文件中即可抑制这些启动警告(根据https://pyinstaller.readthedocs.io/en/stable/spec-files.html#giving-运行时python选项):
exe = EXE(pyz,
a.scripts,
[('W ignore', None, 'OPTION')],
# ...
Run Code Online (Sandbox Code Playgroud)
由于spec文件实际上是一个 python 脚本,您可以替换pathex为os.getcwd()并确保您已经os在spec文件中导入模块。
我试过在Windows 10同Python 3.7.4和pyinstaller 3.5。有用!
由于您提供了自定义spec文件,因此您的基本构建命令应更改为:
pyinstaller xxx.spec
Run Code Online (Sandbox Code Playgroud)
请让我知道它是否有效。
| 归档时间: |
|
| 查看次数: |
2649 次 |
| 最近记录: |