问题描述
我正在尝试使用 Pyinstaller 为我的 Pygame 程序生成设置。 该程序有 1 个 main.py 文件,可导入 4 个其他 .py 文件(config.py、snake.py、fruit.py、game.py)。 因此,在安装 Pyinstaller 后,我只需运行:
pyinstaller --onefile main.py
它正常生成所有文件。但是当我尝试运行 dist 文件夹中的 main.exe 文件时,会发生以下情况:
pygame 2.0.1 (SDL 2.0.14,Python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "main.py",line 6,in <module>
File "<frozen importlib._bootstrap>",line 991,in _find_and_load
File "<frozen importlib._bootstrap>",line 975,in _find_and_load_unlocked
File "<frozen importlib._bootstrap>",line 671,in _load_unlocked
File "c:\users\lucena\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",line 493,in exec_module
exec(bytecode,module.__dict__)
File "game.py",line 2,module.__dict__)
File "config.py",line 74,in <module>
File "config.py",line 33,in img
FileNotFoundError: No such file or directory.
[2468] Failed to execute script main
我尝试修改 .spec 文件中的数据数组,但我不知道我是否做得对,因为我仍然收到错误消息。
有人可以帮我找出导致错误的原因吗?谢谢。
我使用的是 Windows 10、Python 3.8.5 和 Pygame 2.0.1。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)