Python_pip镜像问题

1.报错描述

1
2
3
4
5
6
7
8
D:\desktop\我的项目> pip install --upgrade pip
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: pip in d:\pythonproject\python\lib\site-packages (23.3.2)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001E30562B6D0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': /pypi/simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001E30562BD00>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': /pypi/simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001E30562BDC0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': /pypi/simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001E30562BF40>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': /pypi/simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001E3056600A0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': /pypi/simple/pip/

2.解决办法

解决方法:出现该错误信息是因为pip源连接证书验证失败,将pip源调整为国内的源就可以了

下面是收集的一些国内的pip源:

阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

如果想要永久修改pip源,可按照如下操作:

  1. 找到系统盘下C:\Users\用户名\AppData\Roaming
  2. 查看在Roaming文件夹下有没有一个pip文件夹,如果没有创建一个;
  3. 进入pip文件夹,创建一个pip.ini文件;
  4. 使用记事本的方式打开pip.ini文件,写入:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple # 指定下载源
trusted-host = mirrors.aliyun.com # 指定域名

1_tzlViFoc9Mkz2Z18mL5nLw