python设置镜像源临时和永久两种方式

77 Lv2

背景

在安装某些python packages的时候因为国内的网络问题可能导致安装失败,所以需要切换到国内的镜像源。

临时

trusted-host是添加域名信任,-i 后面跟镜像源

1
pip install requests -I --trusted-host pypi.tuna.tsinghua.edu.cn -i https://pypi.tuna.tsinghua.edu.cn/simple

永久

trusted-host是添加域名信任

1
2
3
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

pip config set global.trusted-host "pypi.tuna.tsinghua.edu.cn"

常见的镜像网站如下

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple

  • 标题: python设置镜像源临时和永久两种方式
  • 作者: 77
  • 创建于 : 2025-01-21 17:42:02
  • 更新于 : 2025-01-21 17:49:10
  • 链接: https://www.jiaheqi.cloud/2025/01/21/python设置镜像源临时和永久两种方式/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
python设置镜像源临时和永久两种方式