Bootstrap

conda 创建环境失败故障解决记录

Anaconda中使用conda创建新环境失败

电脑系统:win 10
环境:Anaconda
创建方法:使用conda来创建环境

创建失败提醒:

(base) C:\Users\Ruixue_Time>conda create -n vilg python=3.8
Collecting package metadata (current_repodata.json): failed

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

    Traceback (most recent call last):
      File "D:\program\Anaconda\lib\site-packages\conda\core\subdir_data.py", line 531, in fetch_repodata_remote_request
        resp.raise_for_status()
      File "D:\program\Anaconda\lib\site-packages\requests\models.py", line 1021, in raise_for_status
        raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch/current_repodata.json

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "D:\program\Anaconda\lib\site-packages\requests\models.py", line 971, in json
        return complexjson.loads(self.text, **kwargs)
      File "D:\program\Anaconda\lib\site-packages\simplejson\__init__.py", line 514, in loads
        return _default_decoder.decode(s)
      File "D:\program\Anaconda\lib\site-packages\simplejson\decoder.py", line 386, in decode
        obj, end = self.raw_decode(s)
      File "D:\program\Anaconda\lib\site-packages\simplejson\decoder.py", line 416, in raw_decode
        return self.scan_once(s, idx=_w(s, idx).end())
    simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "D:\program\Anaconda\lib\site-packages\conda\exceptions.py", line 1129, in __call__
        return func(*args, **kwargs)
      File "D:\program\Anaconda\lib\site-packages\conda\cli\main.py", line 86, in main_subshell
        exit_code = do_call(args, p)
      File "D:\program\Anaconda\lib\site-packages\conda\cli\conda_argparse.py", line 93, in do_call
        return getattr(module, func_name)(args, parser)
      File "D:\program\Anaconda\lib\site-packages\conda\notices\core.py", line 72, in wrapper
        return_value = func(*args, **kwargs)
      File "D:\program\Anaconda\lib\site-packages\conda\cli\main_create.py", line 43, in execute
        install(args, parser, 'create')
      File "D:\program\Anaconda\lib\site-packages\conda\cli\install.py", line 261, in install
        unlink_link_transaction = solver.solve_for_transaction(
      File "D:\program\Anaconda\lib\site-packages\conda\core\solve.py", line 156, in solve_for_transaction
        unlink_precs, link_precs = self.solve_for_diff(update_modifier, deps_modifier,
      File "D:\program\Anaconda\lib\site-packages\conda\core\solve.py", line 199, in solve_for_diff
        final_precs = self.solve_final_state(update_modifier, deps_modifier, prune, ignore_pinned,
      File "D:\program\Anaconda\lib\site-packages\conda\core\solve.py", line 304, in solve_final_state
        ssc = self._collect_all_metadata(ssc)
      File "D:\program\Anaconda\lib\site-packages\conda\common\io.py", line 86, in decorated
        return f(*args, **kwds)
      File "D:\program\Anaconda\lib\site-packages\conda\core\solve.py", line 467, in _collect_all_metadata
        index, r = self._prepare(prepared_specs)
      File "D:\program\Anaconda\lib\site-packages\conda\core\solve.py", line 1061, in _prepare
        reduced_index = get_reduced_index(self.prefix, self.channels,
      File "D:\program\Anaconda\lib\site-packages\conda\core\index.py", line 301, in get_reduced_index
        new_records = SubdirData.query_all(spec, channels=channels, subdirs=subdirs,
      File "D:\program\Anaconda\lib\site-packages\conda\core\subdir_data.py", line 137, in query_all
        result = tuple(concat(executor.map(subdir_query, channel_urls)))
      File "D:\program\Anaconda\lib\concurrent\futures\_base.py", line 609, in result_iterator
        yield fs.pop().result()
      File "D:\program\Anaconda\lib\concurrent\futures\_base.py", line 439, in result
        return self.__get_result()
      File "D:\program\Anaconda\lib\concurrent\futures\_base.py", line 391, in __get_result
        raise self._exception
      File "D:\program\Anaconda\lib\concurrent\futures\thread.py", line 58, in run
        result = self.fn(*self.args, **self.kwargs)
      File "D:\program\Anaconda\lib\site-packages\conda\core\subdir_data.py", line 129, in <lambda>
        subdir_query = lambda url: tuple(SubdirData(Channel(url), repodata_fn=repodata_fn).query(
      File "D:\program\Anaconda\lib\site-packages\conda\core\subdir_data.py", line 142, in query
        self.load()
      File "D:\program\Anaconda\lib\site-packages\conda\core\subdir_data.py", line 207, in load
        _internal_state = self._load()
      File "D:\program\Anaconda\lib\site-packages\conda\core\subdir_data.py", line 277, in _load
        raw_repodata_str = fetch_repodata_remote_request(
      File "D:\program\Anaconda\lib\site-packages\conda\core\subdir_data.py", line 587, in fetch_repodata_remote_request
        raise UnavailableInvalidChannel(
      File "D:\program\Anaconda\lib\site-packages\conda\exceptions.py", line 464, in __init__
        body = response.json()
      File "D:\program\Anaconda\lib\site-packages\requests\models.py", line 975, in json
        raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
    requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

`$ D:\program\Anaconda\Scripts\conda-script.py create -n vilg python=3.8`

  environment variables:
                 CIO_TEST=<not set>
        CONDA_DEFAULT_ENV=base
                CONDA_EXE=D:\program\Anaconda\condabin\..\Scripts\conda.exe
               CONDA_EXES="D:\program\Anaconda\condabin\..\Scripts\conda.exe"
             CONDA_PREFIX=D:\program\Anaconda
    CONDA_PROMPT_MODIFIER=(base)
         CONDA_PYTHON_EXE=D:\program\Anaconda\python.exe
               CONDA_ROOT=D:\program\Anaconda
              CONDA_SHLVL=1
           CURL_CA_BUNDLE=<not set>
                 HOMEPATH=\Users\Ruixue_Time
                     PATH=D:\program\Anaconda;D:\program\Anaconda\Library\mingw-w64\bin;D:\progr
                          am\Anaconda\Library\usr\bin;D:\program\Anaconda\Library\bin;D:\program
                          \Anaconda\Scripts;D:\program\Anaconda\bin;D:\program\Anaconda\condabin
                          ;D:\program\java8\bin;D:\program\Java1.8\bin;D:\program\Java1.8;D:\pro
                          gram\java8;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\p
                          rogram\VMware16\bin;C:\windows\system32;C:\windows;C:\windows\System32
                          \Wbem;C:\windows\System32\WindowsPowerShell\v1.0;C:\windows\System32\O
                          penSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Windows\s
                          ystem32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\Window
                          sPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program
                          Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program
                          Files (x86)\Microsoft SQL Server\150\Tools\Binn;C:\Program
                          Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft
                          SQL Server\150\DTS\Binn;C:\Program Files (x86)\Windows
                          Kits\8.1\Windows Performance Toolkit;C:\Program Files\dotnet;D:\progra
                          m\Anaconda;D:\program\Anaconda\Scripts;D:\program\Anaconda\Library\bin
                          ;C:\Program Files (x86)\Microsoft SQL Server\160\Tools\Binn;C:\Program
                          Files\Microsoft SQL Server\160\Tools\Binn;C:\Program Files\Microsoft
                          SQL Server\160\DTS\Binn;D:\program\MySQL5.5\bin;D:\program\TortoiseSVN
                          \bin;D:\program\MATLAB\R2022b\runtime\win64;D:\program\MATLAB\R2022b\b
                          in;C:\Users\Ruixue_Time\AppData\Local\Microsoft\WindowsApps;.;D:\progr
                          am\Pycharm2023\PyCharm Community Edition
                          2023.3.2\bin;.;D:\program\IntelliJ_IDEA\IntelliJ IDEA 2024.1\bin;.
             PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\Windows
                          PowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL
                          Server\150\Tools\PowerShell\Modules\;C:\Program Files (x86)\Microsoft
                          SQL Server\160\Tools\PowerShell\Modules\
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : base
    active env location : D:\program\Anaconda
            shell level : 1
       user config file : C:\Users\Ruixue_Time\.condarc
 populated config files : C:\Users\Ruixue_Time\.condarc
          conda version : 22.9.0
    conda-build version : 3.22.0
         python version : 3.9.13.final.0
       virtual packages : __cuda=12.6=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : D:\program\Anaconda  (writable)
      conda av data dir : D:\program\Anaconda\etc\conda
  conda av metadata url : None
           channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : D:\program\Anaconda\pkgs
                          C:\Users\Ruixue_Time\.conda\pkgs
                          C:\Users\Ruixue_Time\AppData\Local\conda\conda\pkgs
       envs directories : D:\program\Anaconda\envs
                          C:\Users\Ruixue_Time\.conda\envs
                          C:\Users\Ruixue_Time\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.13 Windows/10 Windows/10.0.19045
          administrator : False
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.

Upload did not complete.

解决办法

步骤一

输入conda config --show-sources,查看是否有 .condarc文件

(base) C:\Users\Ruixue_Time>conda config --show-sources
==> C:\Users\Ruixue_Time\.condarc <==
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: True
report_errors: False

之后会显示这个文件的路径和文件内容

步骤二

删除.condarc文件

步骤三

继续创新自己的新环境,就可以啦

参考文章

参考博文

;