conda create创建虚拟环境失败

Posted 玛丽莲茼蒿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了conda create创建虚拟环境失败相关的知识,希望对你有一定的参考价值。

一、问题

conda的其他命令没问题,比如conda env list命令是可以照常运行的,但是运行

conda create --name 环境名

命令会报出以下错误:

C:\\Users\\DELL>conda create -n recsys
Collecting package metadata (current_repodata.json): done
Solving environment: done

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "D:\\anaconda\\lib\\site-packages\\conda\\exceptions.py", line 1079, in __call__
        return func(*args, **kwargs)
      File "D:\\anaconda\\lib\\site-packages\\conda\\cli\\main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "D:\\anaconda\\lib\\site-packages\\conda\\cli\\conda_argparse.py", line 82, in do_call
        return getattr(module, func_name)(args, parser)
      File "D:\\anaconda\\lib\\site-packages\\conda\\cli\\main_create.py", line 37, in execute
        install(args, parser, 'create')
      File "D:\\anaconda\\lib\\site-packages\\conda\\cli\\install.py", line 261, in install
        unlink_link_transaction = solver.solve_for_transaction(
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\solve.py", line 123, in solve_for_transaction
        self._notify_conda_outdated(link_precs)
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\solve.py", line 960, in _notify_conda_outdated
        SubdirData.query_all(conda_newer_spec, self.channels, self.subdirs,
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\subdir_data.py", line 105, in query_all
        result = tuple(concat(executor.map(subdir_query, channel_urls)))
      File "D:\\anaconda\\lib\\concurrent\\futures\\_base.py", line 611, in result_iterator
        yield fs.pop().result()
      File "D:\\anaconda\\lib\\concurrent\\futures\\_base.py", line 439, in result
        return self.__get_result()
      File "D:\\anaconda\\lib\\concurrent\\futures\\_base.py", line 388, in __get_result
        raise self._exception
      File "D:\\anaconda\\lib\\concurrent\\futures\\thread.py", line 57, in run
        result = self.fn(*self.args, **self.kwargs)
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\subdir_data.py", line 97, in <lambda>
        subdir_query = lambda url: tuple(SubdirData(Channel(url), repodata_fn=repodata_fn).query(
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\subdir_data.py", line 110, in query
        self.load()
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\subdir_data.py", line 174, in load
        _internal_state = self._load()
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\subdir_data.py", line 236, in _load
        _internal_state = self._read_local_repdata(mod_etag_headers.get('_etag'),
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\subdir_data.py", line 311, in _read_local_repdata
        _internal_state = self._process_raw_repodata_str(raw_repodata_str)
      File "D:\\anaconda\\lib\\site-packages\\conda\\core\\subdir_data.py", line 349, in _process_raw_repodata_str
        json_obj = json.loads(raw_repodata_str or '')
      File "D:\\anaconda\\lib\\json\\__init__.py", line 357, in loads
        return _default_decoder.decode(s)
      File "D:\\anaconda\\lib\\json\\decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "D:\\anaconda\\lib\\json\\decoder.py", line 353, in raw_decode
        obj, end = self.scan_once(s, idx)
    json.decoder.JSONDecodeError: Unterminated string starting at: line 1081865 column 5 (char 33141916)

`$ D:\\anaconda\\Scripts\\conda-script.py create -n recsys`

  environment variables:
                 CCHZPATH=D:\\软件\\TEX\\CTeX_2.9.2.164_Full\\CTeX\\cct\\fonts
                 CCPKPATH=D:\\软件\\TEX\\CTeX_2.9.2.164_Full\\CTeX\\fonts\\pk\\modeless\\cct\\dpi$d
                 CIO_TEST=<not set>
                CLASSPATH=.;C:\\Program Files\\Java\\jdk1.8.0_131\\lib;C:\\Program
                          Files\\Java\\jdk1.8.0_131\\lib\\dt.jar;C:\\Program
                          Files\\Java\\jdk1.8.0_131\\lib\\tools.jar;
                CONDA_EXE=D:\\anaconda\\condabin\\..\\Scripts\\conda.exe
               CONDA_EXES="D:\\anaconda\\condabin\\..\\Scripts\\conda.exe"
               CONDA_ROOT=D:\\anaconda
                 HOMEPATH=\\Users\\DELL
                     PATH=D:\\anaconda;D:\\anaconda\\Library\\mingw-w64\\bin;D:\\anaconda\\Library\\usr\\
                          bin;D:\\anaconda\\Library\\bin;D:\\anaconda\\Scripts;D:\\anaconda\\bin;D:\\软件\\
                          TEX\\CTeX_2.9.2.164_Full\\UserData\\miktex\\bin;D;\\软件\\TEX\\CTeX_2.9.2.164_F
                          ull\\MiKTeX\\miktex\\bin;D;\\软件\\TEX\\CTeX_2.9.2.164_Full\\CTeX\\ctex\\bin;D;\\软
                          件\\TEX\\CTeX_2.9.2.164_Full\\CTeX\\cct\\bin;D;\\软件\\TEX\\CTeX_2.9.2.164_Full\\C
                          TeX\\ty\\bin;D;\\软件\\TEX\\CTeX_2.9.2.164_Full\\Ghostscript\\gs9.05\\bin;D;\\软件\\
                          TEX\\CTeX_2.9.2.164_Full\\GSview\\gsview;D;\\软件\\TEX\\CTeX_2.9.2.164_Full\\Wi
                          nEdt;D;\\Program Files\\Microsoft SQL Server\\110\\DTS\\Binn\\;D:\\软件\\S;L_SER
                          VER_2012\\共享功能目录1\\110\\Tools\\Binn\\;D:\\软件;SQL_SERVER_2012\\共享功能目录1\\110\\DTS
                          \\Binn\\;D:\\软件;SQL_SERVER_2012\\共享功能目录2\\110\\Tools\\Binn\\ManagementStudio\\;
                          C:\\Pr;gram Files (x86)\\Microsoft Visual Studio
                          10.0\\Common7\\IDE\\PrivateAssemblies\\;C:\\Program
                          Files\\Java\\jdk1.8.0_131\\bin;C:\\Program Files\\PuTTY\\;D:\\gtk+\\bin;C:\\WIN
                          DOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\
                          WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program
                          Files\\Java\\jdk1.8.0_131\\jre\\bin;F:\\android Project\\SDK\\platform-
                          tools;D:\\软件\\Git\\cmd;D:\\软件\\DEV_C++\\Dev-
                          Cpp\\MinGW64\\bin;D:\\MinGW64\\bin;D:\\nodejs\\;D:\\2_environment\\apache-mave
                          n-3.8.4\\bin;D:\\2_environment\\mysql-5.7.19\\bin;C:\\Users\\DELL\\AppData\\Lo
                          cal\\Programs\\Python\\Python38\\Scripts\\;C:\\Users\\DELL\\AppData\\Local\\Prog
                          rams\\Python\\Python38\\;D:\\anaconda;D:\\anaconda\\Library\\mingw-w64\\bin;D:
                          \\anaconda\\Library\\usr\\bin;D:\\anaconda\\Library\\bin;D:\\anaconda\\Scripts;
                          C:\\Users\\DELL\\AppData\\Local\\Microsoft\\WindowsApps;C:\\texlive\\2018\\bin\\
                          win32;D:\\软件\\pycharm\\PyCharm 2019.3.3\\bin;;C:\\WINDOWS\\system32;D:\\软件\\VS
                          Code\\bin;D:\\nodejs\\;;D:\\软件\\IntelliJ IDEA 2021.3.2\\bin;
             PSMODULEPATH=C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\Windows
                          PowerShell\\v1.0\\Modules
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
       user config file : C:\\Users\\DELL\\.condarc
 populated config files : C:\\Users\\DELL\\.condarc
          conda version : 4.8.3
    conda-build version : 3.18.11
         python version : 3.8.3.final.0
       virtual packages : __cuda=12.0
       base environment : D:\\anaconda  (writable)
           channel URLs : https://mirrors.aliyun.com/anaconda/cloud/ursky/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/ursky/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/stackless/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/stackless/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/simpleitk/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/simpleitk/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/rdkit/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/rdkit/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/rapidsai/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/rapidsai/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/qiime2/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/qiime2/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/pyviz/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/pyviz/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/pytorch3d/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/pytorch3d/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/pytorch-test/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/pytorch-test/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/pytorch/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/pytorch/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/psi4/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/psi4/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/plotly/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/plotly/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/omnia/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/omnia/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/ohmeta/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/ohmeta/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/numba/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/numba/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/msys2/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/msys2/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/mordred-descriptor/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/mordred-descriptor/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/menpo/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/menpo/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/matsci/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/matsci/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/intel/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/intel/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/idaholab/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/idaholab/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/fermi/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/fermi/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/fastai/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/fastai/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/dglteam/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/dglteam/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/deepmodeling/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/deepmodeling/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/conda-forge/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/conda-forge/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/caffe2/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/caffe2/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/c4aarch64/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/c4aarch64/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/bioconda/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/bioconda/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/biobakery/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/biobakery/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/auto/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/auto/noarch
                          https://mirrors.aliyun.com/anaconda/cloud/Paddle/win-64
                          https://mirrors.aliyun.com/anaconda/cloud/Paddle/noarch
                          https://mirrors.aliyun.com/anaconda/pkgs/r/win-64
                          https://mirrors.aliyun.com/anaconda/pkgs/r/noarch
                          https://mirrors.aliyun.com/anaconda/pkgs/msys2/win-64
                          https://mirrors.aliyun.com/anaconda/pkgs/msys2/noarch
                          https://mirrors.aliyun.com/anaconda/pkgs/main/win-64
                          https://mirrors.aliyun.com/anaconda/pkgs/main/noarch
                          https://mirrors.aliyun.com/anaconda/pkgs/free/win-64
                          https://mirrors.aliyun.com/anaconda/pkgs/free/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
          package cache : D:\\anaconda\\pkgs
                          C:\\Users\\DELL\\.conda\\pkgs
                          C:\\Users\\DELL\\AppData\\Local\\conda\\conda\\pkgs
       envs directories : D:\\anaconda\\envs
                          C:\\Users\\DELL\\.conda\\envs
                          C:\\Users\\DELL\\AppData\\Local\\conda\\conda\\envs
               platform : win-64
             user-agent : conda/4.8.3 requests/2.24.0 CPython/3.8.3 Windows/10 Windows/10.0.19041
          administrator : False
             netrc file : None
           offline mode : False

二、解决方法

借鉴:http://events.jianshu.io/p/f53d93ad63c3

根据错误提示,json文件解读出错。什么json文件呢?我猜是conda的配置文件C:\\Users\\DELL\\.condarc,因为我之前改过conda的配置文件,所以猜测是这里出的问题。

本来想的是,直接搜一下.condarc文件的默认内容粘上去,但是这样就没有镜像的配置了。所以我没用默认的.condarc文件,而是搜了一段配置了清华源镜像的

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

更改完成后,在命令行输入以下命令完成配置的更新:

conda config --set show_channel_urls yes

以上是关于conda create创建虚拟环境失败的主要内容,如果未能解决你的问题,请参考以下文章

在指定目录下建立conda虚拟环境后发现没有环境名(激活失败)的解决办法

Conda create 卡在“解决包规范”上

Anaconda-- conda 创建、激活、退出、删除虚拟环境(转)

anaconda创建删除虚拟环境指令

【Anaconda】conda创建虚拟环境不报错,但是虚拟环境无法生成的解决办法

conda 创建/删除/重命名 环境