conda安装的国内镜像配置,实现快速下载

anaconda的所有的软件包全部在国外,安装起来很麻烦,关键是下载速度慢,而且经常中断,所以需要配置国内安装的镜像,下载速度就很快了。

2020/12/08更新:
最近发现·douban·源比较快

pip install pythonModuleName -i https://pypi.douban.com/simple

一、conda换国内源

1.1 查看源

命令

conda config --show-sources

显示结果

==> /home/xxx/.condarc <==
channels:

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

这里有两个源,一个是清华的源,另一个是默认的源

1.2 添加源(这里以添加清华源为例,当然也可以选择其他的源)

命令

conda config --add channels xxx

操作:

#添加清华的源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

运行成果后,使用显示源查看是否添加成功(conda config --show-sources)

1.3 其他可选的源(还有更多的可以网上搜索,这里不一一列举)

中科大的源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ 
阿里云的源
conda config --add channels http://mirrors.aliyun.com/pypi/simple/

1.4 移除源

命令

conda config --remove channels xxxx

移除全部

conda config --remove channels

例如,移除清华源

conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'

恢复默认源:

conda config --remove-key channels

设置显示源路径

conda config --set show_channel_urls yes

运行

 conda clean -i

清除索引缓存,保证用的是镜像站提供的索引。

二、pip 源的修改:

永久修改:
Linux:

修改 pip.conf 文件 (没有就创建一个)

vi /home/xxx/.config/pip/pip.conf

修改内容如下:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple12

有时候经常出现的异常大概有几种:
1、pip 不是虚拟环境路径
那么使用 which python得到python编译器路径: xxx/xxx/anaconda3/envs/nlp/bin/python,然后:

xxx/xxx/anaconda3/envs/nlp/bin/python -m pip install xxxx

2、pip 源更新为国内后,却总是找不到
可能是上面永久修改[/home/.config/pip/pip.conf]设置了 global url
将文本中的删除,然后就可以了
再不行,可以试试

pip install xxxx -i ttps://pypi.tuna.tsinghua.edu.cn/simple

3、pip更新

pip install --upgrade pip
python -m pip install --upgrade pip

附:清华大学开源软件镜像站
在这里插入图片描述
pypi 镜像使用帮助
pypi 镜像每 5 分钟同步一次。

临时使用
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
注意,simple 不能少, 是 https 而不是 http

设为默认
升级 pip 到最新的版本 (>=10.0.0) 后进行配置:

pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:

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

  • 7
    点赞
  • 69
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值