pip更换源,换成国内镜像

Windows 换源

pip永久换源

第一种

  • 在 C:\Users\你的用户名 目录下新建pip文件夹

  • 在新建的pip目录下新建pip.ini (新建txt,把后缀改成ini)

  • 用记事本打开写入

[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

或者

[global] 
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn  
# 上面的trusted-host参数解决可能会提示不受信任的问题

第二种

pip永久换源:(个人推荐阿里云的源)
在cmd命令行中输入上述命令即可。

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

使用上述命令以后
在这里插入图片描述

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

临时

 # 以使用清华大学的镜像源安装matplotlib为例
 pip install matplotlib -i  https://pypi.tuna.tsinghua.edu.cn/simple/

如果提示不信任则用这个:

pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com SomePackage

后面再要加参数的话就如这样:

pip install -i http://e.pypi.python.org --trusted-host e.pypi.python.org --upgrade pip #--upgrade 升级pip
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/# 换回默认源pip config unset global.index-url

一些常用的国内源:

清华大学:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:https://mirrors.aliyun.com/pypi/simple

中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple

豆瓣:http://pypi.douban.com/simple
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值