Python国内常用镜像源汇总
warning:
这篇文章距离上次修改已过204天,其中的内容可能已经有所变动。
在Python中,使用国内镜像源可以加快包的下载速度,特别是在中国大陆地区,以下是一些常用的Python镜像源:
- 阿里云:http://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 https://pypi.tuna.tsinghua.edu.cn/simple some-package
以下是一个简单的Python脚本,用于自动切换到阿里云的镜像源:
# Python 自动切换到阿里云镜像源
import os
def set_aliyun_mirror():
os.system('pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/')
# 调用函数设置镜像源
set_aliyun_mirror()
这个脚本会将全局的pip镜像源设置为阿里云的镜像源。
评论已关闭