更换pip源到国内镜像源

没落的情绪 2020-08-17 AM 687℃ 0条

国内镜像
阿里云 https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
临时使用方法
在pip 指令的后面加上 -i 国内源

pip install 包名 -i 镜像地址

如:

pip install sip -i https://mirrors.aliyun.com/pypi/simple/

永久修改pip源的方法
Windows系统
在user目录下创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,填入下面的内容

[global]
index-url = https://mirrors.aliyun.com/pypi/simple

Linux系统
修改(不存在就新建) ~/.pip/pip.conf 文件,填入下面的内容

[global]
index-url = https://mirrors.aliyun.com/pypi/simple

报错解决
如果报错 "The repository located at mirrors.aliyun.com is not a trusted ... "
临时解决

pip install sip -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

永久解决
在pip.conf文件添加下面的内容

[global]
trusted-host=mirrors.aliyun.com
标签: Python

非特殊说明,本博所有文章均为博主原创。

评论啦~