Bootstrap

踩坑指南!anaconda新建环境出错解决!又是猛男落泪的一天!

我在配置环境时出现一些问题,冲动之下直接删除了anaconda/envs/xxx下的那个环境包,在重新使用conda create创建环境时,就出现了下面的问题:(忘记截图了,在网上看到类似的错误copy过来作为错误代码示例)

Collecting package metadata (current_repodata.json): failed

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

    Traceback (most recent call last):
      File "D:\Anaconda3\lib\site-packages\conda\exceptions.py", line 1079, in __call__
        return func(*args, **kwargs)
      File "D:\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "D:\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 82, in do_call
        return getattr(module, func_name)(args, parser)
      File "D:\Anaconda3\lib\site-packages\conda\cli\main_install.py", line 20, in execute
        install(args, parser, 'install')
      File "D:\Anaconda3\lib\site-packages\conda\cli\install.py", line 265, in install
        should_retry_solve=(_should_retry_unfrozen or repodata_fn != repodata_fns[-1]),
      File "D:\Anaconda3\lib\site-packages\conda\core\solve.py", line 117, in solve_for_transaction
        should_retry_solve)
      File "D:\Anaconda3\lib\site-packages\conda\core\solve.py", line 158, in solve_for_diff
        force_remove, should_retry_solve)
      File "D:\Anaconda3\lib\site-packages\conda\core\solve.py", line 262, in solve_final_state
        ssc = self._collect_all_metadata(ssc)
      File "D:\Anaconda3\lib\site-packages\conda\common\io.py", line 88, in decorated
        return f(*args, **kwds)
      File "D:\Anaconda3\lib\site-packages\conda\core\solve.py", line 415, in _collect_all_metadata
        index, r = self._prepare(prepared_specs)
      File "D:\Anaconda3\lib\site-packages\conda\core\solve.py", line 1011, in _prepare
        self.subdirs, prepared_specs, self._repodata_fn)
      File "D:\Anaconda3\lib\site-packages\conda\core\index.py", line 228, in get_reduced_index
        repodata_fn=repodata_fn)
      File "D:\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 105, in query_all
        result = tuple(concat(executor.map(subdir_query, channel_urls)))
      File "D:\Anaconda3\lib\concurrent\futures\_base.py", line 598, in result_iterator
        yield fs.pop().result()
      File "D:\Anaconda3\lib\concurrent\futures\_base.py", line 435, in result
        return self.__get_result()
      File "D:\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
        raise self._exception
      File "D:\Anaconda3\lib\concurrent\futures\thread.py", line 57, in run
        result = self.fn(*self.args, **self.kwargs)
      File "D:\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 98, in <lambda>
        package_ref_or_match_spec))
      File "D:\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 110, in query
        self.load()
      File "D:\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 174, in load
        _internal_state = self._load()
      File "D:\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 276, in _load
        _internal_state = self._process_raw_repodata_str(raw_repodata_str)
      File "D:\Anaconda3\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:\Anaconda3\lib\json\__init__.py", line 348, in loads
        return _default_decoder.decode(s)
      File "D:\Anaconda3\lib\json\decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "D:\Anaconda3\lib\json\decoder.py", line 353, in raw_decode
        obj, end = self.scan_once(s, idx)
    json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 41 (char 40)

  $ D:\Anaconda3\Scripts\conda-script.py install geopandas

  environment variables:
                 CIO_TEST=<not set>
               CONDA_ROOT=D:\Anaconda3
                 HOMEPATH=\Users\ZY
          MOZ_PLUGIN_PATH=D:\Foxit Reader\plugins\
                     PATH=C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\Sys
                          tem32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program
                          Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program
                          Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files
                          (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA
                          Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin\;C:\Program
                          Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\system32;C:\WINDOW
                          S;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
                          ;C:\WINDOWS\System32\OpenSSH\;D:\Python\Python37;D:\Python\Python37\Li
                          b\site-packages;C:\Program Files (x86)\Microsoft SQL
                          Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL
                          Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL
                          Server\100\DTS\Binn\;D:\MATLAB\R2018a\bin;D:\SQL2019\Microsoft SQL
                          Server\x86\150\Tools\Binn\;D:\SQL2019\Microsoft SQL
                          Server\150\Tools\Binn\;D:\SQL2019\Microsoft SQL
                          Server\x86\150\DTS\Binn\;D:\SQL2019\Microsoft SQL
                          Server\150\DTS\Binn\;D:\SQL2019\Microsoft SQL Server\Client SDK\ODBC\1
                          70\Tools\Binn\;D:\Anaconda3\Scripts;C:\Users\ZY\AppData\Local\Microsof
                          t\WindowsApps;D:\Python\Python37;D:\Python\Python37\Scripts;C:\Users\Z
                          Y\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3
                          (64-bit);D:\Python\Python37\Lib\site-packages;D:\Anaconda3\Lib\site-pa
                          ckages;D:\Anaconda3\Lib\;D:\Anaconda3\Library\bin;D:\Anaconda3\Scripts
                          ;
             PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\Windows
                          PowerShell\v1.0\Modules;D:\SQL2019\Microsoft SQL
                          Server\x86\150\Tools\PowerShell\Modules\
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
       user config file : C:\Users\ZY\.condarc
 populated config files : C:\Users\ZY\.condarc
          conda version : 4.8.2
    conda-build version : 3.18.11
         python version : 3.7.6.final.0
       virtual packages : __cuda=10.2
       base environment : D:\Anaconda3  (writable)
           channel URLs : https://anaconda.org/win-64
                          https://anaconda.org/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:\Anaconda3\pkgs
                          C:\Users\ZY\.conda\pkgs
                          C:\Users\ZY\AppData\Local\conda\conda\pkgs
       envs directories : D:\Anaconda3\envs
                          C:\Users\ZY\.conda\envs
                          C:\Users\ZY\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.6 Windows/10 Windows/10.0.17763
          administrator : False
             netrc file : None
           offline mode : False

尝试过卸载重装anaconda,重新下载anaconda,甚至进入到 D:\Anaconda3\lib\json\decoder.py 这个里面去找那个奇葩的double quotes问题,均无果!!!(周末就要报告,我周四环境还没配好,嘤嘤嘤)

后来终于找到一个大神的解答,亲测有效:

I have tried to find solutions for almost five days. And I finally solved my problems with the help of others.
For my case, when I reinstalled anaconda on my machine, a .condarc file was automatically generated. Then error occurred when I used conda install and conda create command.
After I delete .condarc file, everything goes well. Hope this way can help others with the same problem. Use the following command to check the path of the .condarc file, then delete it/them.
conda config --show-sources

意思是,用conda config --show-sources查出.condarc文件的位置在哪里,然后把这个文件删掉就行了,这个文件是我们在重新换源的时候出现的。
bingo问题解决,希望每次记录踩坑心得可以让我攒攒人品,少遇环境bug。

;