前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >anaconda下载包时网络连接错误的解决方法

anaconda下载包时网络连接错误的解决方法

作者头像
狼啸风云
修改2022-09-02 20:06:28
2.9K0
修改2022-09-02 20:06:28
举报
文章被收录于专栏:计算机视觉理论及其实现

不论用conda安装一些python的包,还是创新独立的编程环境时,出现以下报错:

在anaconda安装完毕之后,通常要做的就是配置更新,这一步主要将conda下载源从国外的网站转移到国内网站,这样就可以大大缩减下载时间,防止出现以上网络问题。该问题的解决方法只有一种,那就是更换conda下载源。下载源通常位于~/.condarc文件中,或者/home/用户名/.condarc文件中。

查看源的方式:

方法1:除了vim,也可用cat/more/less显示

代码语言:javascript
复制
vi ~/.condarc           #对于root用户
vi /home/xuran/.condarc #对于普通用户

方法2:用conda show命令

>> conda config --show #全部显示

>> conda config --show channels #只显示channels部分

代码语言:javascript
复制
conda config --show          #全部显示
conda config --show channels #只显示channels部分

更换源的方式:

方法1:直接使用清华源的.condarc文件,并放在相应的目录下。

下载地址https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

方法2:在(base)中输入命令,添加源,并移除默认选项(default)

代码语言:javascript
复制
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --remove channels defaults
conda config --set show_channel_urls yes

方法3:先用vim打开./condarc文件,然后手动添加源

代码语言:javascript
复制
#open .condarc file
vi /home/xuran/.condarc
 
#add the following code
ssl_verify: true
channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

show_channel_urls: true

注意,channels不需要太多,前两个就够用。

有人反应用“https”会报错,用“http”更稳定。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/12/29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档