问题:python的pip install安装报错
(jie_py3.6) user@llms01:~/jie/myStudy/CasEE/CasEE$ pip install transformers==4.9.1
Collecting transformers==4.9.1
Cache entry deserialization failed, entry ignored
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/transformers/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) - skipping
Could not find a version that satisfies the requirement transformers==4.9.1 (from versions: )
No matching distribution found for transformers==4.9.1
You are using pip version 9.0.1, however version 24.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
解决方法
解决 SSL 证书问题
SSL 证书验证失败通常发生在 Python 环境设置不正确或本地证书链问题时。可以采取以下方法:
1.临时关闭 SSL 验证(亲测有效)
加上 --trusted-host
参数,忽略 SSL 验证错误:
pip install transformers==4.9.1 --trusted-host pypi.tuna.tsinghua.edu.cn -i https://pypi.tuna.tsinghua.edu.cn/simple
这里使用清华镜像源,你可以根据需要替换成其他源,如阿里云源。
2.永久配置 pip 源并关闭 SSL 验证
在用户目录下创建或修改 pip.conf
(Linux)或 pip.ini
(Windows)文件:
mkdir -p ~/.pip
vim ~/.pip/pip.conf
在 pip.conf
中添加以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
这样,pip
会默认使用清华镜像源并跳过 SSL 验证。