pip 切换镜像源

在安装python的包时,使用pip安装,但会出现 “https://pypi.python.org/simple/scipy/” 访问不了了或者速度慢的现象。

切换国内的镜像源,可以提高下载速度。

国内镜像源

http://pypi.douban.com/simple/ 豆瓣
http://mirrors.aliyun.com/pypi/simple/ 阿里
http://pypi.hustunique.com/simple/ 华中理工大学
http://pypi.sdutlinux.org/simple/ 山东理工大学
http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学

切换方法

1、临时切换

在 pip 命令中增加 -i 参数进行切换,如:

pip install tensorflow -i https://pypi.douban.com/simple/

2、永久切换

需要修改配置文件。

编辑文件 vim ~/.pip/pip.conf

[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 tensorflow

就会自动走豆瓣的源。

你可能感兴趣的:(python)