pip安装python库总是下载超时,有什么解决方法吗?
PHP中文网
PHP中文网 2017-04-17 11:18:34
0
11
1307

如题,最近经常出现下载超时的情况,怎么也安装不了,有什么解决方法吗?

PHP中文网
PHP中文网

认证0级讲师

reply all(11)
PHPzhong

Create a file ~/.pip/pip.conf with the following content

[global]
index-url = http://b.pypi.python.org/simple
[install]
use-mirrors = true
mirrors = http://b.pypi.python.org

http://pypi.python.org/mirrors

左手右手慢动作

It is recommended to use the mirror: http://e.pypi.python.org. This is the IP of Beijing and will be much faster.
In addition, you can set a timeout = 6000 in the [global] block to avoid incomplete downloading of the installation package when the network is slow.

[global]
timeout = 6000
index-url = http://e.pypi.python.org/simple
[install]
use-mirrors = true
mirrors = http://e.pypi.python.org
阿神

You can also specify the installation source of a single library

pip install flask -i http://pypi.v2ex.com/simple
黄舟

Or try the v2ex source

Create the file pip.conf under ~/.pip/ (if you don’t have one already) and fill in the following content:

[global]
index-url = http://pypi.v2ex.com/simple
迷茫

Regarding the new version of HTTP insecurity error, I will give you a template.

[global]
timeout = 6000
index-url = http://pypi.douban.com/simple/ 
[install]
use-mirrors = true
mirrors = http://pypi.douban.com/simple/ 
trusted-host = pypi.douban.com
阿神
pip install -i https://pypi.doubanio.com/simple/ 包名

The addresses provided by many answers are either closed or redirected, and the new version must use https. It is recommended to use the above one for domestic mirrors.
I personally do not recommend changing the source address by default to avoid security risks.

迷茫

Check the mirror activity in PyPI Mirror. Just select the appropriate image for the CN region.

The specific configuration method is as follows
Using a mirror
Single Usage:

pip install -i http://<mirror>/simple <package>

Global settings:
Add ~/.pip/pip.conf that includes:

[global]
index-url = http://<mirror>/simple

洪涛

The above mainly talks about mirror, another option is proxy:

pip install package --proxy=[代理地址]

Posting some useful Pypi mirrors:

  • Douban

  • University of Science and Technology of China

刘奇

It is February 20, 2017. The most convenient source is https://pypi.tuna.tsinghua.ed...
For example,
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu
Soon, pip Same thing

阿神

The latest news, Tsinghua University is closing the PyPi source

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template