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

Python3.11执行pip install pyinstaller时触发ImportError错误求助

解决pip安装PyInstaller时出现的ImportError: cannot import name 'Mapping' from 'collections'错误

错误根源

你的Python 3.11环境中,pip依赖的html5lib版本过旧——它尝试从collections模块导入Mapping类,但该类在Python 3.10及以上版本已迁移至collections.abc模块,导致导入失败。

解决方案

方案一:升级pip到最新版本

执行以下命令,自动更新pip及其依赖的所有兼容库:

python -m pip install --upgrade pip

方案二:手动修复html5lib的导入问题(方案一失效时使用)

找到报错路径对应的文件:
C:\Users\JUAN ANDRES TELLEZ V\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pip\_vendor\html5lib\_trie\_base.py
打开文件后,将第3行的:

from collections import Mapping

修改为:

from collections.abc import Mapping

方案三:用内置工具重新安装pip

执行命令彻底重置并升级pip:

python -m ensurepip --upgrade

完成上述任一操作后,重新执行pip install pyinstaller即可正常安装。

内容的提问来源于stack exchange,提问作者JUAN ANDRES TELLEZ VANEGAS

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 08:49:55