首页 > 解决方案 > 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

解决方案


尝试这个:

pyinstaller -F --add-data="<PATH_OF_FILE_IN_YOUR_ENV>/pygame/freesansbold.ttf;/pygame/freesansbold.ttf" main.py

基本上,您需要从虚拟环境中找到 freesansbold.ttf 并将其显式添加到包中。


推荐阅读