2020-09-03解决pip install安装非常慢[Errno 101] 网络不可达问题

转载链接:http://huanyouchen.github.io/2019/11/21/pip-install-package-very-slow/

问题描述

使用pip安装seaborn提示:

 sudo python3.5 -m pip install seaborn

Collecting seaborn

  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb25d444fd0>: Failed to establish a new connection: [Errno 101] 网络不可达',)': /packages/a8/76/220ba4420459d9c4c9c9587c6ce607bf56c25b3d3d2de62056efe482dadc/seaborn-0.9.0-py3-none-any.whl

尝试加入default-time=100这个参数,提示:

sudo python3.5 -m pip --default-time=100 install seaborn

Collecting seaborn
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=100.0)",)': /packages/a8/76/220ba4420459d9c4c9c9587c6ce607bf56c25b3d3d2de62056efe482dadc/seaborn-0.9.0-py3-none-any.whl

 

等了半天还是安装不了

解决方法

在pip后面加入-i参数,比如:-i https://pypi.tuna.tsinghua.edu.cn/simple

sudo python3.5 -m pip --default-time=100 install seaborn -i https://pypi.tuna.tsinghua.edu.cn/s

另外,可以将默认时间延迟增大避免超时

--default-timeout=10000 -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install tensorflow --default-timeout=10000 -i https://pypi.doubanio.com/simple/

 

下载的飞快~

据说可以一劳永逸的方法,但我还没试过,过程如下:

mkdir ~/.pip
cd ~/.pip
touch pip.conf
gedit pip.conf

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

cat pip.conf
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值