python使用pyinstaller打包时出现raise ValueError("Entry points must be listed in groups")问题记录
【背景】
这几天使用pyinstaller打包时出现一直出现raise ValueError("Entry points must be listed in groups")的报错提示,报错详情如下,折腾了好几天,参考了很多资料和AI问答,都没搞定。
后面经过多次尝试,终于解决了,记录下解决过程,以备后续使用,也方便后来者。
【报错详情】
Traceback (most recent call last):
File "d:\python\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "d:\python\lib\site-packages\PyInstaller\__main__.py", line 194, in _console_script_run
run()
File "d:\python\lib\site-packages\PyInstaller\__main__.py", line 180, in run
run_build(pyi_config, spec_file, **vars(args))
File "d:\python\lib\site-packages\PyInstaller\__main__.py", line 61, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 1019, in main
build(specfile, distpath, workpath, clean_build)
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 944, in build
exec(code, spec_namespace)
File
noarchive=False,
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 373, in __init__
self.hookspath += discover_hook_directories()
File "d:\python\lib\site-packages\PyInstaller\isolated\_parent.py", line 403, in wrapped
return call(function, *args, **kwargs)
File "d:\python\lib\site-packages\PyInstaller\isolated\_parent.py", line 372, in call
return isolated.call(function, *args, **kwargs)
File "d:\python\lib\site-packages\PyInstaller\isolated\_parent.py", line 302, in call
raise RuntimeError(f"Child process call to {function.__name__}() failed with:\n" + output)
RuntimeError: Child process call to discover_hook_directories() failed with:
File "d:\python\lib\site-packages\pkg_resources\__init__.py", line 2936, in get_entry_map
ep_map = self._ep_map
File "d:\python\lib\site-packages\pkg_resources\__init__.py", line 2902, in __getattr__
raise AttributeError(attr)
AttributeError: _ep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\python\lib\site-packages\PyInstaller\isolated\_child.py", line 63, in run_next_command
output = function(*args, **kwargs)
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 99, in discover_hook_directories
entry_points = sorted(entry_points, key=lambda x: x.module_name == "_pyinstaller_hooks_contrib.hooks")
File "d:\python\lib\site-packages\pkg_resources\__init__.py", line 712, in <genexpr>
for entry in dist.get_entry_map(group).values()
File "d:\python\lib\site-packages\pkg_resources\__init__.py", line 2939, in get_entry_map
self._get_metadata('entry_points.txt'), self
File "d:\python\lib\site-packages\pkg_resources\__init__.py", line 2606, in parse_map
raise ValueError("Entry points must be listed in groups")
ValueError: Entry points must be listed in groups
【尝试过程】
1、卸载pyinstaller,并重新安装pyinstaller 5.13.2,无效;
2、尝试将之前备份过的pyinstaller包覆盖替换,无效;
3、尝试降级pyinstaller至最近的三个版本,pip install pyinstaller==5.10,无效;
4、尝试更新打包涉及到的相关包,无效;
【解决方法】
尝试继续降级pyinstaller的版本,成功解决问题:
pip install pyinstaller==4.5
【怀疑】
可能是安装的python版本是3.7版本,太旧了,只能使用比较老版本的pyinstaller,新版本会出现不兼容的情况,后续大家遇到类似的问题,可以参考一下。