我最近使用 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 并将其显式添加到捆绑包中。