conda 换成清华的源_Conda和pip更换国内源

本文介绍了如何将Conda和pip的源更改为清华大学的镜像源,以提高软件包下载速度。对于Conda,需修改用户目录下的`.condarc`文件,删除`-defaults`并添加清华大学的镜像URL。对于pip,可以临时或永久地更改源,使用`pip config set`命令设置全局index-url为清华大学的pypi镜像。
摘要由CSDN通过智能技术生成

更换Conda源

各系统都可以通过修改用户目录下的 .condarc 文件,直接修改Conda源。

Windows文件路径在C:\Users\yourname\.condarc,Mac文件路径在/Users/yourname/.condarc, 如没有或者无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。

直接将下面任意一个国内源覆盖到 ".condarc" 文件里面去即可。

channels:

- defaults

show_channel_urls: true

channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda

default_channels:

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

custom_channels:

conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

remote_read_timeout_secs: 600.0

其中 remote_read_timeout_secs就是设置超时时间,可以通过conda config --set remote_read_timeout_secs 600.0语句设置,或者直接在上面文件里加最后那句

2.中科大源(USTC)

channels:

- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/

- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/

show_channel_urls: true

「注意」:一定要将 ".condarc" 文件里面默认的 “-defaults” 语句删除!否则会报错CondaHTTPError: HTTP 000 CONNECTION FAILED。

「提示」:如果“-defaults” 语句已经删除,但是使用conda 的时候,仍然报错CondaHTTPError: HTTP 000 CONNECTION FAILED,则把 ".condarc" 文件里面的所有“https”修改成“http”即可。

更换pip源

清华的pypi 镜像每 5 分钟同步一次,所以刚更换好,可能依旧很慢。

临时使用pip

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 【需要安装的包】

永久更换pip源

临时使用镜像站来升级 pip

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U

该语句会升级 pip 到最新的版本,只要 版本>=10.0.0即可进行后面的配置

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

这样就pip源就更换完毕了。

等待五分钟之后,使用pip 安装软件包或更新pip时就不再需要 “ -i 指定临时镜像站了” 。

参考博客

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值