安装anaconda及修改conda config 的channels/default_channels

先说一下安装anaconda的方法,很简单,就是去官网下载然后在本地安装

bash Anaconda3-4.4.0-Linux-x86_64.sh

这个过程中要耐心,会有提问,需要输入yes来回应,并且需要按很多的回车,总之,看见让输入yes的就输入yes,不要用回车代替,其中有个关键的地方,就是是否允许anaconda将环境变量写到bashrc中:


# added by Anaconda3 4.4.0 installer
export PATH="/home/zz/anaconda3/bin:$PATH"

一定要同意,否则启动系统后它找不到anaconda的路径就没办法用了啊。

解下来就是修改conda的安装源问题。
使用如下命令可以查看conda的配置

zz@T630:~$ conda config --show
add_anaconda_token: True
add_pip_as_python_dependency: True
allow_non_channel_urls: True
allow_softlinks: True
always_copy: False
always_softlink: False
always_yes: False
anaconda_upload: None
auto_update_conda: True
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: True
channels:
  - defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
create_default_packages: []
custom_channels:
  pkgs/free: https://repo.continuum.io/
  pkgs/r: https://repo.continuum.io/
  pkgs/pro: https://repo.continuum.io/
custom_multichannels:
  defaults: ["https://repo.continuum.io/pkgs/free", "https://repo.continuum.io/pkgs/r", "https://repo.continuum.io/pkgs/pro"]
  local: []
default_channels:
  - https://repo.continuum.io/pkgs/free
  - https://repo.continuum.io/pkgs/r
  - https://repo.continuum.io/pkgs/pro
disallow: []
envs_dirs:
  - /home/zz/anaconda3/envs
  - /home/zz/.conda/envs
force: False
json: False
local_repodata_ttl: 1
migrated_channel_aliases: []
offline: False
path_conflict: clobber
  nned_packages: []
▽kgs_dirs:
  - /home/zz/anaconda3/pkgs
  - /home/zz/.conda/pkgs
proxy_servers: {}
quiet: False
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
rollback_enabled: True
shortcuts: True
show_channel_urls: None
ssl_verify: True
track_features: []
use_pip: True
verbosity: 0

上面是默认的配置,这个有什么问题呢,就是在安装有些包儿的时候它会提示超时,无法连接。我在网上查看说要修改一下源地址,也就是对应的channels和default_channels中的地址。但是呢,不知道它的配置文件在哪里,上面那一坨信息是直接用conda config –show这个命令显示出来的,找不到它的配置文件,网上说有个默认的配置文件在~/.condarc,但是找了半天没有。怎么办呢?我仔细看了一下
conda config的帮助,发现可以用命令行的方式修改配置信息,如conda config –append channels https://xxxxxx ,然后试了一下,用conda config –show查看可以添加进去,此时再看就有了~/.condarc这个文件了。突然明白了,原来这个文件是这样使用的,即conda先检查是否存在~/.condarc,有的话就加载里面的配置,没有的话就用默认的配置,但是不知道它的默认配置是保存在哪里的,不管了。
于是赶紧修改了~/.condarc如下:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - defaults
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  - https://repo.continuum.io/pkgs/free
  - https://repo.continuum.io/pkgs/r
  - https://repo.continuum.io/pkgs/pro

之后再查看一下:

zz@T630:~$ conda config --show
add_anaconda_token: True
add_pip_as_python_dependency: True
allow_non_channel_urls: True
allow_softlinks: True
always_copy: False
always_softlink: False
always_yes: False
anaconda_upload: None
auto_update_conda: True
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: True
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
create_default_packages: []
custom_channels:
  anaconda/pkgs/free: https://mirrors.tuna.tsinghua.edu.cn/
  anaconda/cloud/conda-forge: https://mirrors.tuna.tsinghua.edu.cn/
  pkgs/free: https://repo.continuum.io/
  pkgs/r: https://repo.continuum.io/
  pkgs/pro: https://repo.continuum.io/
custom_multichannels:
  defaults: ["https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free", "https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge", "https://repo.continuum.io/pkgs/free", "https://repo.continuum.io/pkgs/r", "https://repo.continuum.io/pkgs/pro"]
  local: []
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  - https://repo.continuum.io/pkgs/free
  - https://repo.continuum.io/pkgs/r
  - https://repo.continuum.io/pkgs/pro
disallow: []
envs_dirs:
  - /home/zz/anaconda3/envs
  - /home/zz/.conda/envs
force: False
json: False
local_repodata_ttl: 1
migrated_channel_aliases: []
offline: False
path_conflict: clobber
pinned_packages: []
pkgs_dirs:
  - /home/zz/anaconda3/pkgs
  - /home/zz/.conda/pkgs
proxy_servers: {}
quiet: False
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
rollback_enabled: True
shortcuts: True
show_channel_urls: None
ssl_verify: True
track_features: []
use_pip: True
verbosity: 0
这个命令是用来添加一个名为'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'的镜像源到conda的配置中。镜像源是用来加速软件包的下载和安装的,通过使用镜像源,可以提高下载速度并减少网络延迟。\[1\]所以,运行这个命令后,conda将会从该镜像源下载免费的软件包。\[1\] #### 引用[.reference_title] - *1* [conda如何添加,删除镜像channel,管理虚拟环境,以及其他常见命令。](https://blog.csdn.net/qq_43391414/article/details/115071599)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Conda 替换镜像源方法尽头,再也不用到处搜镜像源地址](https://blog.csdn.net/adreammaker/article/details/123396951)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [将Anaconda设置为国内镜像源的方法](https://blog.csdn.net/weixin_49779629/article/details/124053811)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值