python安装pip install报错Could not fetch URL https://pypi.org/simple/pip/...更换镜像源

一. 现象

pycharm使用 pip install xxx安装包时,一直报错:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=No
ne)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation
 of protocol (_ssl.c:1123)'))': /simple/flask/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=No
ne)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation
 of protocol (_ssl.c:1123)'))': /simple/flask/
ERROR: Could not find a version that satisfies the requirement xxx (from versions
: none)
ERROR: No matching distribution found for xxx
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming th
e ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exce
eded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in vio
lation of protocol (_ssl.c:1123)'))) - skipping

二. 原因:

pypi.python.org在国内被墙了,无法从python官网url下载。

三. 解决办法:

一. 临时使用

更改为国内的镜像源:(xxx为安装的包)

pip install xxx -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple xxx
  • 豆瓣(douban) http://pypi.douban.com/simple/

  • 阿里云 http://mirrors.aliyun.com/pypi/simple/

  • 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

  • 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

  • 华为云:https://repo.huaweicloud.com/repository/pypi/simple

注:还尝试了一种方法,是加上–trusted-host

执行 pip install xxx -i https://pypi.org/simple --trusted-host pypi.org 但是仍然报错

这次应该url对了,但是还是一直WARNING

二. 永久更改

在python的命令提示符中运行以下语句,该条语句将pip的下载源永久更改为某个镜像站,这里以清华大学开源镜像站为例:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

三. 永久更改

1. Windows
windows环境下

在用户目录中创建一个文件夹,该文件夹的命名为pip;在该pip文件夹中新建一个文件pip.ini,pip.ini的内容如下:(完整路径:C:\Users\用户名\pip\pip.ini)

[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple 
[install]  
trusted-host=pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true  
timeout = 600
Windows(示例win10)

1、文件管理器文件路径地址栏敲:%APPDATA% 回车,快速进入 C:\Users\电脑用户\AppData\Roaming 文件夹中
2、新建 pip 文件夹并在文件夹中新建 pip.ini 配置文件
3、新增 pip.ini 配置文件内容

[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
2. Linux or Mac

首先在用户目录下新建.pip文件夹

mkdir ~/.pip

在该目录下新建配置文件pip.conf,输入如下内容,保存:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
3. Pycharm中修改库下载源

在setting中按如下路径打开包下载
在这里插入图片描述
点击Manage Respositories,点击+添加国内源路径即可







破壳的小企鹅

python更换国内镜像源三种实用方法

SevenBerry

python安装pip install报错Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirm

牧竹子

Python环境安装并永久配置镜像源

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坦笑&&life

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值