pyinstaller 打包 matplotlib:Failed to execute script ... WindowsPath ... matplotlibrc

本文记述 pyinstaller 打包使用了 matplotlib 的程序遇到的问题。 假设我要打包 graphics_main.py

Failed to execute script

  • 报错信息:Failed to execute script.

  • 解决方案:改用 -F 选项打包,只生成单个 .exe 文件并运行,看看错误是什么:
    pyinstaller --clean -F graphics_main.py

  • 也可以直接进入下一步。

TypeError: expected str, bytes or os.PathLike object, not WindowsPath

  • 报错信息:TypeError: expected str, bytes or os.PathLike object, not WindowsPath.
    在生成的过程中,终端里包含如上一句话(仔细找一找,是不是有 TypeError)。

  • 解决方案:与下一个相同。

No such file or directory matplotlibrc

  • 报错信息: No such file or directory matplotlibrc

-F(或-c)生成的文件运行后发现这句话并闪退。(闪退有点快可以手机录个视频看看)。

  • 解决方案:更新 pyinstaller,并进入下一步。
    pip install --upgrade pyinstaller
    在这里插入图片描述

Failed to determine matplotlib’s data directory

  • 报错信息: Failed to determine matplotlib’s data directory
    打包过程中出现这个错误,随即打包中止。
  • 解决方案:卸载 pathlib
    pip uninstall pathlib

Cannot find existing PySide6 plugin directories

这个和matplotlib无关,但是也是我遇到的问题于是记录于此。

  • 报错信息: Cannot find existing PySide6 plugin directories
    打包过程中出现这个错误,打包中止。
  • 解决方案:由于PySide6 的路径名出现中文无法识别,将 site-packages里的 PySide6 拷贝到随便一个没有中文和空格的路径里,然后用 -p 指定。
    这里我拷贝到了 D:/Qt 的文件夹下:

pyinstaller --clean -F -p D:/Qt graphics_main.py
在这里插入图片描述


参考资料

  1. No such file or directory matplotlibrc

  2. Failed to determine matplotlib’s data directory

  3. Cannot find existing PyQt5 plugin directories

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值