【python】使用pip国内源,解决pip安装速度慢的问题

1.常用源

我们使用pip安装python模块的时候可能会出现很慢的情况,甚至有时候就直接爆红提示错误或提示失败了,这时候我们可以改为国内的源,下载速度会快很多,以下几个是比较常用的国内源

url
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云 https://mirrors.aliyun.com/pypi/simple/
豆瓣 https://pypi.doubanio.com/simple/

2.临时使用

只要在使用pip安装模块的时候在后面加上-i 选项指定源即可,例如使用清华源下载numpy

pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple/

3.设为默认

如果已经都想要默认使用某个源进行pip下载,我们可以修改pip的配置文件

pip config set global.index-url 源

例如设置成清华源:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

猜你喜欢

转载自blog.csdn.net/qq_39147299/article/details/108234417