Pip安装使用国内源的两种方法

pip安装后使用pip安装第三方库默认使用的是国外源,一般安装慢而且不是很稳定,结果还会提示安装失败。

国外源不行,可以使用国内源,使用国内源一般有两种方法

1.临时更换

在安装的时候带上参数 -i 国内源地址

例如: pip install pytest -i https://pypi.tuna.tsinghua.edu.cn/simple/

 

2. 永久更换(后续安装的时候不用再带参数)

在C:\Users\用户 下面创建文件夹,命名为pip, 再在pip文件夹下面创建pip.ini文件, 文件内容如下:

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

 

 

设置成功后, 再次使用pip安装无需带参数, 会自动从国内源地址下载

 

对了, 这里贴上比较稳定的几个国内源镜像文件地址, 需要的自取.

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

阿里云:https://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/ 

豆瓣:https://pypi.douban.com/simple/

posted @ 2020-11-09 16:35  风不再来  阅读(2756)  评论(1编辑  收藏  举报