windows pip安装模块出现Could not fetch URL https://mirrors.aliyun.com/pypi/simple/pip/

问题描述

执行pip install 发现以下报错:

Could not fetch URL https://pypi.org/simple/requests/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/requests/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))) - skipping

看报错描述,猜测是https证书校验问题,最简单的解决方案是使用http镜像地址,步骤如下:

1、创建pip配置文件

查看配置文件路径:

C:\Users\Loren\PycharmProjects\pythonProject\venv\Scripts>./pip.exe -v config list
For variant 'global', will try loading 'C:\ProgramData\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\EchatDev\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\EchatDev\AppData\Roaming\pip\pip.ini'
For variant 'site', will try loading 'c:\users\echatdev\pycharmprojects\pythonproject\venv\pip.ini'

命令会输出各个级别的pip配置文件路径,这里选择全局配置'global',找到C:\ProgramData\pip\pip.ini文件,如果没有则创建。

2、配置镜像地址

打开pip.ini,添加镜像配置:

[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

这里使用的阿里云的镜像地址,相对速度比较快。需要添加trusted-host。

配置完成之后,重新执行pip install即可成功。

猜你喜欢

转载自blog.csdn.net/huangzhilin2015/article/details/113372083