先说一下安装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