10、pip换源加速下载的方式

pip换源加速下载的方式

pip换源的原因:

在使用Python安装包工具pip时经常会出现下载很慢的情况,这其中有很大一部分原因和pip的源有关,在我们安装python后,通常python解释器自带pip这个工具,但是这里pip是设置的默认源,也就是官方源:
https://pypi.org/simple 这个源在国内的下载速度是很慢的,所以我们为了提高包的下载速度我们可以通过换源来实现。

1、临时换源

临时换源只需要在pip安装包时,加上一个-i参数后接源的url即可:

清华源
pip install markdown -i https://pypi.tuna.tsinghua.edu.cn/simple
阿里源
pip install markdown -i https://mirrors.aliyun.com/pypi/simple/
腾讯源
pip install markdown -i http://mirrors.cloud.tencent.com/pypi/simple
豆瓣源
pip install markdown -i http://pypi.douban.com/simple/

2、永久换源

永久还原是通过修改pip配置文件,修改pip下载路径实现:

清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
换回默认源
pip config unset global.index-url

posted @ 2022-09-28 12:03  wydilearn  阅读(868)  评论(0编辑  收藏  举报