首页 > 解决方案 > PyInstaller:无法为未注册的加载程序类型执行此操作

问题描述

我试图将我的测试游戏变成一个 exe 并且构建运行良好,但是当我运行可执行文件时。它给出了这个错误:

pygame 2.0.0.dev10 (SDL 2.0.12, python 3.8.3)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "main.py", line 7, 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:\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "scene_titleScreen.py", line 63, in <module>
  File "asset_generator.py", line 13, in generateRoundedButtonSurf
  File "site-packages\pygame\sysfont.py", line 370, in SysFont
  File "site-packages\pygame\sysfont.py", line 293, in font_constructor
  File "site-packages\pygame\pkgdata.py", line 50, in getResource
  File "site-packages\pkg_resources\__init__.py", line 1134, in resource_exists
  File "site-packages\pkg_resources\__init__.py", line 1404, in has_resource
  File "site-packages\pkg_resources\__init__.py", line 1472, in _has
NotImplementedError: Can't perform this operation for unregistered loader type
[9904] Failed to execute script main

当我运行脚本时,它工作正常。奇怪的是 pyinstaller 在单脚本游戏中运行良好。或者可能是因为我用我的游戏制作的交叉导入?

My Project Folder
├─ main.py (Imports scene_titleScreen.py and scene_world.py)
├─ render_engine.py (Only imports pygame)
├─ asset_generator.py (Only imports pygame)
├─ scene_titleScreen.py (Imports render_engine.py and asset_generator.py)
└─ scene_world.py (Imports render_engine.py and asset_generator.py)

还有什么要知道来解决这个问题吗?

标签: pythonpython-3.xpygamepyinstaller

解决方案


推荐阅读