Python国内常用镜像源和使用方法
warning:
这篇文章距离上次修改已过183天,其中的内容可能已经有所变动。
在Python中,使用国内镜像源可以加快包的下载速度,尤其是在网络不稳定或者无法访问默认PyPI时非常有用。以下是几个常用的Python镜像源以及如何使用它们:
- 阿里云: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/
- 中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/simple/
你可以在使用pip安装包时指定镜像源,例如:
pip install -i https://mirrors.aliyun.com/pypi/simple/ some-package
此命令会从阿里云镜像源安装名为some-package
的Python包。
如果你想要永久修改pip默认的镜像源,可以创建或修改配置文件pip.conf
(Unix系统位于~/.pip/pip.conf
,Windows系统位于%HOME%\pip\pip.ini
),例如:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
这样配置后,你使用pip安装包时会默认使用这个镜像源。
评论已关闭