python - 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)
还有什么要知道来解决这个问题吗?
解决方案
推荐阅读
- capl - 编写测试用例以确认 CAPL 中的计数器信号值
- ios - 我购买了一件商品,需要使用 paypal 节点 js 在一笔交易中将金额分配给两个不同的商家或卖家
- javascript - 使用 AJAX 响应填充 JSON 对象
- sql - 使用 SQL 在组的两个值之间生成组代码
- android - 无法为 CameraX Preview 和 ImageAnalysis 设置自定义分辨率
- algorithm - 多边形算法中的多边形
- swift - DispatchWorkItem 如何取消递归过程?
- javascript - Javascript 自动触发按钮提交带有动态操作链接的 php 表单
- postgresql - 如何使用自定义类型在 postgres(数组)类型中创建类型
- sql - SQL Server SMO 查询性能(2014 与 2017)