国内 pip 镜像源服务域名

Python官方https://pypi.python.org/simple/
阿里云https://mirrors.aliyun.com/pypi/simple/
清华大学https://pypi.tuna.tsinghua.edu.cn/simple/
中国科技大学https://pypi.mirrors.ustc.edu.cn/simple/
中国科学技术大学https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣http://pypi.douban.com/simple/
腾讯云https://mirrors.cloud.tencent.com/pypi/simple/
华中理工大学http://pypi.hustunique.com/
山东理工大学http://pypi.sdutlinux.org/
pip 国内镜像源列表

pip

临时使用

以下均为清华镜像源为例,其他镜像服务器同理更换域名即可。

pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple some-package

注意:

simple 不能少。
pip 要求使用 https ,因此需要 https 而不是 http

设为默认

升级 pip 到最新的版本后进行配置:

python -m pip install --upgrade pip
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:

python -m pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple --upgrade pip

配置多个镜像源

如果您想配置多个镜像源平衡负载,可在已经替换 index-url 的情况下通过以下方式继续增加源站:

pip config set global.extra-index-url "<url1> <url2>..."

请自行替换引号内的内容,源地址之间需要有空格

例如

pip config set global.extra-index-url "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"

PDM

通过如下命令设置默认镜像:

pdm config pypi.url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

Poetry

通过以下命令为单个项目设置首选镜像:

poetry source add --priority=primary mirrors https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

通过以下命令为单个项目设置补充镜像:

poetry source add --priority=supplemental mirrors https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

Poetry 尚未支持全局设置镜像。

使用全局镜像的临时方案是将 Poetry 的安装器切换回 pip,如下所示。但该方式会在将来的版本中停止支持。

poetry config experimental.new-installer false

Homebrew

export HOMEBREW_PIP_INDEX_URL="https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
,
轩源的网络日志微信公众号:源码跳动
微信公众号: 源码跳动
轩源和他的朋友们②群0914
更多技术讨论加微信群

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注