添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

anaconda换清华源后报错解决(1)

在之前的 一篇换源教程 中,提到

各系统都可以通过修改用户目录下的 .condarc 文件来使用 TUNA 镜像源。Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。

通过执行 conda config --set show_channel_urls yes 生成 .condarc 后,进行修改时要将里面的全部内容替换成

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - 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
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

不要直接在后面黏贴,否则你的 .condarc 内容将是

show_channel_urls: true
channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - 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
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud


多出来一行

show_channel_urls: true


这将导致后续执行 conda clean -i 报错

>>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
    Traceback (most recent call last):
      File "conda/exceptions.py", line 1118, in __call__
      File "conda/cli/main.py", line 61, in main_subshell
      File "conda/base/context.py", line 399, in __init__
      File "conda/common/configuration.py", line 1291, in __init__
      File "conda/common/configuration.py", line 1297, in _set_search_path
      File "conda/common/configuration.py", line 488, in load_file_configs
      File "conda/common/configuration.py", line 488, in <genexpr>
      File "conda/common/configuration.py", line 461, in _file_loader
      File "conda/common/configuration.py", line 387, in make_raw_parameters_from_file
      File "conda/common/serialize.py", line 57, in yaml_round_trip_load
      File "ruamel/yaml/main.py", line 434, in load
      File "ruamel/yaml/constructor.py", line 121, in get_single_data
      File "ruamel/yaml/constructor.py", line 131, in construct_document
      File "ruamel/yaml/constructor.py", line 1569, in construct_yaml_map
      File "ruamel/yaml/constructor.py", line 1453, in construct_mapping
      File "ruamel/yaml/constructor.py", line 294, in check_mapping_key
    ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
      in "/root/.condarc", line 1, column 1
    found duplicate key "show_channel_urls" with value "True" (original value: "True")
      in "/root/.condarc", line 4, column 1
    To suppress this check see:
        http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
`$ /root/miniconda3/conda.exe install --offline --file /root/miniconda3/pkgs/env.txt -yp /root/miniconda3`
  environment variables:
                 CIO_TEST=<not set>
           CONDA_CHANNELS=https://repo.anaconda.com/pkgs/main,https://repo.anaconda.com/pkgs/r
                CONDA_EXE=/root/miniconda3/bin/conda
CONDA_EXTRA_SAFETY_CHECKS=no
          CONDA_PKGS_DIRS=/root/miniconda3/pkgs
         CONDA_PYTHON_EXE=/root/miniconda3/bin/python
               CONDA_ROOT=/root/miniconda3/install_tmp/_MEIbiVABH
      CONDA_SAFETY_CHECKS=disabled
              CONDA_SHLVL=0
           CURL_CA_BUNDLE=<not set>
          LD_LIBRARY_PATH=/root/miniconda3/install_tmp/_MEIbiVABH
               LD_PRELOAD=<not set>
      OLD_LD_LIBRARY_PATH=
                     PATH=/root/miniconda3/condabin:/usr/anaconda3/bin:/usr/local/sbin:/usr/loca
                          l/bin:/usr/sbin:/usr/bin:/root/bin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
     active environment : None
            shell level : 0
       user config file : /root/.condarc
 populated config files : 
          conda version : 22.11.1
    conda-build version : not installed
         python version : 3.9.15.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.17=0
                          __linux=3.10.0=0
                          __unix=0=0
       base environment : /root/miniconda3/install_tmp/_MEIbiVABH  (read only)
      conda av data dir : /root/miniconda3/install_tmp/_MEIbiVABH/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /root/miniconda3/install_tmp/_MEIbiVABH/pkgs
                          /root/.conda/pkgs
       envs directories : /root/.conda/envs
                          /root/miniconda3/install_tmp/_MEIbiVABH/envs
               platform : linux-64
             user-agent : conda/22.11.1 requests/2.28.1 CPython/3.9.15 Linux/3.10.0-1160.45.1.el7.x86_64 centos/7.6.1810 glibc/2.17
                UID:GID : 0:0
             netrc file : None
           offline mode : False