将工作Python脚本转换为EXE(Python)后出错

2024-04-27 00:56:30 发布

您现在位置:Python中文网/ 问答频道 /正文

最近我用pygame做了一个简单的游戏,它完美无瑕。现在我想把它转换成EXE。我是用pyinstaller完成的:pyinstaller --onefile dodge1.py

但是当我运行EXE时,我得到了这个错误,我不知道该如何处理它,因为我是一个初学者,以前从未见过它:

pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "dodge1.py", line 168, in <module>
  File "dodge1.py", line 97, in game_intro
  File "site-packages\pygame\pkgdata.py", line 50, in getResource
  File "site-packages\pkg_resources\__init__.py", line 1129, in resource_exists
  File "site-packages\pkg_resources\__init__.py", line 1399, in has_resource
  File "site-packages\pkg_resources\__init__.py", line 1452, in _has
NotImplementedError: Can't perform this operation for unregistered loader type
[5588] Failed to execute script dodge

1个

这是第168和97行中的内容,因为这些似乎是有问题的行:

168:game_intro()
97:LargeText = pygame.font.Font('freesansbold.ttf', 70)

如果你想要完整的170行代码,请发表评论,我只是没有把这个问题写得太长。你知道吗


Tags: inpygameinitpackageslinesitepkg