pip加速

pip下载安装Python库很慢,可使用.

pip下载安装Python库很慢,可使用国内镜像网站加速,操作方法有二。

命令行使用参数项-i

 

[root@localhost ~]# pip install -i https://pypi.douban.com/simple/ sqlalchemy

pip添加配置文件

上面方法每次安装Python库时都要输入镜像网址,很麻烦。可以给pip添加配置文件,以后使用pip安装Python镜像库就不用带 “-i” 参数项。
# Window 完整地址:C:\Users\%UserName%\pip\pip.ini

# LINUX查看用户主目录下有没有”~/.pip/pip.conf”文件,没有则创建。

 

[root@localhost ~]# mkdir .pip
[root@localhost ~]# touch .pip/pip.conf

打开文件,添加以下配置项

 

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

可选镜像网址

豆瓣

 

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

阿里云

 

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

清华大学

 

[global] 
index-url=https://pypi.tuna.tsinghua.edu.cn/simple 
[install] 
trusted-host=pypi.tuna.tsinghua.edu.cn