Python中pip安装bleach库报错,求助
pyton 2.7.5 执行 pip install bleach 报错,没找出来什么原因导致的问题,请大家帮忙看看,主要日志如下:
Downloading from URL https://pypi.python.org/packages/85/3e/cf449cf1b5004e87510b9368e7a5f1acd8831c2d6691edd3c62a0823f98f/html5lib-1.0.1.tar.gz#md5=942a0688d6bdf20d087c9805c40182ad (from https://pypi.python.org/simple/html5lib/) Running setup.py egg_info for package html5libTraceback (most recent call last): File "<string>", line 16, in <module> File "/root/maodou/venv/build/html5lib/setup.py", line 54, in <module> MarkerEvaluation = pkg_resources.MarkerEvaluation AttributeError: 'module' object has no attribute 'MarkerEvaluation' Complete output from command python setup.py egg_info: Traceback (most recent call last):File “<string>”, line 16, in <module>
File “/root/maodou/venv/build/html5lib/setup.py”, line 54, in <module>
MarkerEvaluation = pkg_resources.MarkerEvaluationAttributeError: ‘module’ object has no attribute ‘MarkerEvaluation’
Cleaning up…
Removing temporary dir /root/maodou/venv/build… Command python setup.py egg_info failed with error code 1 in /root/maodou/venv/build/html5lib
Exception information: Traceback (most recent call last): File “/root/maodou/venv/lib/python2.7/site-packages/pip/basecommand.py”, line 134, in main status = self.run(options, args) File “/root/maodou/venv/lib/python2.7/site-packages/pip/commands/install.py”, line 236, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File “/root/maodou/venv/lib/python2.7/site-packages/pip/req.py”, line 1134, in prepare_files req_to_install.run_egg_info() File “/root/maodou/venv/lib/python2.7/site-packages/pip/req.py”, line 259, in run_egg_info command_desc=‘python setup.py egg_info’) File “/root/maodou/venv/lib/python2.7/site-packages/pip/util.py”, line 670, in call_subprocess % (command_desc, proc.returncode, cwd)) InstallationError: Command python setup.py egg_info failed with error code 1 in /root/maodou/venv/build/html5lib
Python中pip安装bleach库报错,求助
单独安装 html5lib,执行 pip install html5lib,报错如下:
<pre>
------------------------------------------------------------
/root/maodou/venv/bin/pip run on Wed Feb 21 11:33:50 2018
Downloading/unpacking html5lib
。。。。
Running setup.py egg_info for package html5lib
Traceback (most recent call last):
File “<string>”, line 16, in <module>
File “/root/maodou/venv/build/html5lib/setup.py”, line 54, in <module>
MarkerEvaluation = pkg_resources.MarkerEvaluation
AttributeError: ‘module’ object has no attribute ‘MarkerEvaluation’
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File “<string>”, line 16, in <module>
File “/root/maodou/venv/build/html5lib/setup.py”, line 54, in <module>
MarkerEvaluation = pkg_resources.MarkerEvaluation
AttributeError: ‘module’ object has no attribute ‘MarkerEvaluation’
----------------------------------------
Cleaning up…
Removing temporary dir /root/maodou/venv/build…
Command python setup.py egg_info failed with error code 1 in /root/maodou/venv/build/html5lib
Exception information:
Traceback (most recent call last):
File “/root/maodou/venv/lib/python2.7/site-packages/pip/basecommand.py”, line 134, in main
status = self.run(options, args)
File “/root/maodou/venv/lib/python2.7/site-packages/pip/commands/install.py”, line 236, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File “/root/maodou/venv/lib/python2.7/site-packages/pip/req.py”, line 1134, in prepare_files
req_to_install.run_egg_info()
File “/root/maodou/venv/lib/python2.7/site-packages/pip/req.py”, line 259, in run_egg_info
command_desc=‘python setup.py egg_info’)
File “/root/maodou/venv/lib/python2.7/site-packages/pip/util.py”, line 670, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /root/maodou/venv/build/html5lib
</pre>
问题分析:
pip install bleach 报错通常由网络问题、依赖冲突或环境配置导致。以下是常见解决方案:
1. 网络问题(最常见)
# 使用国内镜像源
pip install bleach -i https://pypi.tuna.tsinghua.edu.cn/simple
# 或使用阿里云镜像
pip install bleach -i https://mirrors.aliyun.com/pypi/simple/
2. 升级pip和setuptools
python -m pip install --upgrade pip setuptools wheel
pip install bleach
3. 清理缓存重试
pip cache purge
pip install bleach --no-cache-dir
4. 检查Python版本兼容性 Bleach 6.0+ 需要 Python ≥3.7,确认版本:
import sys
print(sys.version)
5. 完整环境解决方案
# 创建干净虚拟环境(推荐)
python -m venv clean_env
source clean_env/bin/activate # Linux/Mac
# clean_env\Scripts\activate # Windows
pip install --upgrade pip
pip install bleach -i https://pypi.tuna.tsinghua.edu.cn/simple
如果仍有问题,请提供具体错误信息(复制完整的红色报错文本),常见错误类型:
SSL Certificate Verify Failed→ 添加--trusted-host pypi.org --trusted-host files.pythonhosted.org- 权限错误 → 添加
--user参数或使用管理员权限 - 依赖冲突 → 先安装指定版本:
pip install "bleach<6.0"(兼容旧环境)
一句话建议: 优先使用国内镜像源并确保网络通畅。
是不是 pip/setuptools 版本太低了,装最新版试试
pip install --upgrade pip
pip install --upgrade setuptools
更新一下先
除了版本问题,基本上遇到的 pip 安装报错都是依赖的 devel 找不到,这种错误拿关键字去 google 里搜应该都可以找到。。
问题已解决,解决方法是按照 的方法,升级了 pip 和 setuptools 之后再执行 pip install bleach 后安装成功,感谢
这是基本操作=。=

