You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用pip安装PyInstaller时遭遇pefile相关错误的技术求助

解决pip安装PyInstaller时出现的ValueError: Entry points must be listed in groups错误

问题背景

你在Windows PowerShell中执行pip install pyinstaller时遇到了报错,核心错误是安装依赖pefile时触发了ValueError: Entry points must be listed in groups,完整报错信息如下:

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS F:\coding and website developing\learning PYTHON\FreeCodeCamp\Space Shooter> pip install pyinstaller
正在收集 pyinstaller
使用缓存的 PyInstaller-3.6.tar.gz (3.5 MB)
正在安装构建依赖项... 完成
获取构建wheel的依赖项... 完成
准备wheel元数据... 完成
正在收集 altgraph
使用缓存的 altgraph-0.17-py2.py3-none-any.whl (21 kB)
正在收集 pywin32-ctypes>=0.2.0
使用缓存的 pywin32_ctypes-0.2.0-py2.py3-none-any.whl (28 kB)
正在收集 pefile>=2017.8.1
使用缓存的 pefile-2019.4.18.tar.gz (62 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\users\pbdgr\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\pbdgr\\AppData\\Local\\Temp\\pip-install-a8pv6z1h\\pefile\\setup.py'"'"'; __file__='"'"'C:\\Users\\pbdgr\\AppData\\Local\\Temp\\pip-install-a8pv6z1h\\pefile\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\pbdgr\AppData\Local\Temp\pip-pip-egg-info-xrjitowd'
cwd: C:\Users\pbdgr\AppData\Local\Temp\pip-install-a8pv6z1h\pefile\
Complete output (26 lines):
Traceback (most recent call last):
  File "c:\users\pbdgr\appdata\local\programs\python\python37\lib\site-packages\pkg_resources\__init__.py", line 2857, in get_entry_map
    ep_map = self._ep_map
  File "c:\users\pbdgr\appdata\local\programs\python\python37\lib\site-packages\pkg_resources\__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _ep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\pbdgr\AppData\Local\Temp\pip-install-a8pv6z1h\pefile\setup.py", line 91, in <module>
    'future',
  File "c:\users\pbdgr\appdata\local\programs\python\python37\lib\site-packages\setuptools\__init__.py", line 144, in setup
    _install_setup_requires(attrs)
  File "c:\users\pbdgr\appdata\local\programs\python\python37\lib\site-packages\setuptools\__init__.py", line 133, in _install_setup_requires
    (k, v) for k, v in attrs.items()
  File "c:\users\pbdgr\appdata\local\programs\python\python37\lib\site-packages\setuptools\dist.py", line 443, in __init__
    for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
  File "c:\users\pbdgr\appdata\local\programs\python\python37\lib\site-packages\pkg_resources\__init__.py", line 656, in <genexpr>
    for entry in dist.get_entry_map(group).values()
  File "c:\users\pbdgr\appdata\local\programs\python\python37\lib\site-packages\pkg_resources\__init__.py", line 2860, in get_entry_map
    self._get_metadata('entry_points.txt'), self
  File "c:\users\pbdgr\appdata\local\programs\python\python37\lib\site-packages\pkg_resources\__init__.py", line 2531, in parse_map
    raise ValueError("Entry points must be listed in groups")
ValueError: Entry points must be listed in groups
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info
Check the logs for full command output.

解决方案

我之前也碰到过完全一样的问题,这个错误通常是setuptools、pkg_resources版本过旧或损坏,或者pefile旧版本与Python 3.7环境不兼容导致的,按以下步骤操作就能解决:

  1. 升级pip、setuptools和wheel到最新版本
    先在PowerShell中运行这条命令,更新Python的包管理工具链,修复可能存在的兼容性问题:

    python -m pip install --upgrade pip setuptools wheel
    
  2. 手动安装兼容版本的pefile
    报错中自动安装的pefile 2019.4.18在Python 3.7下可能存在entry points解析问题,我们直接安装更新的稳定版本:

    pip install pefile>=2021.9.3
    
  3. 重新安装PyInstaller
    等pefile安装成功后,再次执行PyInstaller的安装命令:

    pip install pyinstaller
    

问题说明

这个错误的根源是pkg_resources在解析包的entry_points.txt文件时格式不符合预期,旧版本setuptools生成的文件结构可能有问题,或者缓存的包文件损坏。升级工具链可以修复大部分这类格式解析问题,手动安装更新的pefile版本则绕过了旧版本pefile的安装冲突,确保依赖先正常安装,再完成PyInstaller的部署。

内容的提问来源于stack exchange,提问作者rushabh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 16:27:31