小毅
发布于 2024-09-08 / 7 阅读
0
0

python 下载加速

python 下载模块时,默认从官方服务器进行下载,由于官方服务器在国外,因此咱们下载的速度会非常慢,为了加速下载,我们可以使用国内的镜像源。

以 numpy 模块为例,指定使用中科大镜像源

pip install numpy -i https://pypi.mirrors.ustc.edu.cn/simple/

这样我们就从中科大的服务器里下载对应的模块

2024-09-08T13:04:34-pkixzjga.png

我们还可以配置全局都使用该镜像源,这样以后默认就从国内镜像源下载,不用每次都手动输入 -i <url>

pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/

再尝试下载 pandas,可以发现默认就从中科大的 URL 进行下载了

pip install pandas

2024-09-08T13:06:21-nuvrlcca.png

常用镜像源

中科大镜像源

https://pypi.mirrors.ustc.edu.cn/simple/

清华镜像源

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

阿里镜像源

https://mirrors.aliyun.com/pypi/simple

评论