pyinstaller - Pyinstaller 没有这样的文件或目录:
问题描述
我最近使用 pyinstaller 编译了一个 python 3 文件。当我试图跑
./main
它说以下信息:
Fatal Python error: (pygame parachute) Segmentation Fault
Traceback (most recent call last):
File "pygame/pkgdata.py", line 67, in getResource
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/_MEIkMQ7na/pygame/freesansbold.ttf'
Aborted (core dumped)
我确实使用 pygame 模块。
解决方案
尝试这个:
pyinstaller -F --add-data="<PATH_OF_FILE_IN_YOUR_ENV>/pygame/freesansbold.ttf;/pygame/freesansbold.ttf" main.py
基本上,您需要从虚拟环境中找到 freesansbold.ttf 并将其显式添加到包中。
推荐阅读
- r - 如何获取在指定环境中评估调用对象时使用的所有参数的值
- python - 创建将整个图像数据集转换为注释文件(.xml 文件)的自动方法
- css - 使用 nextjs 时 Css 未在生产模式下加载
- vuejs3 - 为什么 Vue3 组合 API 比单纯的辅助类更好?
- node.js - TypeError:res.status 不是错误处理中间件中的函数
- c++ - Excel XLL 如何判断是否正在从公式栏中调用 UDF?
- docker - 如何在分子.yml 的销毁步骤中为 Docker 驱动程序定义环境变量
- python-3.x - 如何在 FastAPI 中将文件多文件上传字段设置为可选字段
- go - 如何优雅地将字节片解码为不同的结构
- javascript - 使用反应测试库进行下一个 seo 测试