Conda无法安装或更新的问题

用conda安装任何东西都报错. 开始怀疑是公司的鬼网络问题.

.condarc重命名, 重新尝试, 一切又很正常, 以为是清华源TUNA的问题, 还想去https://github.com/tuna/ 报错.

后来一次将https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r channel一行在.condarc中删掉后, 一切又正常了. 莫名其妙啊..

最开始时怀疑是 raise UnavailableInvalidChannel(self.url_w_repodata_fn, 404)的问题, 以为是清华源那边缺失channeldata.json导致找不到subdir, 但关键的文件是repodata.json还是存在且一样的. 可能不是TUNA的问题.

  • 官方pkgs/r源 https://repo.anaconda.com/pkgs/r
  • 清华pkgs/r源 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/

于是重新仔细追查错误, 发现这个错误有三处:

  • raise UnavailableInvalidChannel(self.url_w_repodata_fn, 404)
  • raise Response304ContentUnchanged()
  • json.decoder.JSONDecodeError: Unterminated string starting at: line 184947 column 5 (char 5586731)

第一个网络是可以下载对应repodata.json的, 第二个304重定向应该不是, 第三个是json解码的问题. 搜了一下, 找到以下帖子:

JSONDecodeError with on-disk corrupted repodata #7190

噢, 原来还是公司网络的锅. 肯定是之前update repo信息时网络有问题, 于是就出现了污染.

解决办法

conda clean -i

然后重新随便install 个东西, 会重新下载repo信息. 问题解决. NND的公司网络...

附错误内容:

$ conda install numpy
Collecting package metadata (current_repodata.json): failed

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

    Traceback (most recent call last):
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 251, in _load
        raise UnavailableInvalidChannel(self.url_w_repodata_fn, 404)
    conda.exceptions.UnavailableInvalidChannel: The channel is not accessible or is invalid.
      channel name: anaconda/pkgs/r
      channel url: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
      error code: 404

    You will need to adjust your conda configuration to proceed.
    Use `conda config --show channels` to view your configuration's current state,
    and use `conda config --show-sources` to view config file locations.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 248, in _load
        repodata_fn=self.repodata_fn)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 598, in fetch_repodata_remote_request
        raise Response304ContentUnchanged()
    conda.core.subdir_data.Response304ContentUnchanged

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/exceptions.py", line 1079, in __call__
        return func(*args, **kwargs)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/cli/main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 82, in do_call
        return getattr(module, func_name)(args, parser)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 20, in execute
        install(args, parser, 'install')
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/cli/install.py", line 265, in install
        should_retry_solve=(_should_retry_unfrozen or repodata_fn != repodata_fns[-1]),
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/solve.py", line 117, in solve_for_transaction
        should_retry_solve)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/solve.py", line 158, in solve_for_diff
        force_remove, should_retry_solve)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/solve.py", line 262, in solve_final_state
        ssc = self._collect_all_metadata(ssc)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/common/io.py", line 88, in decorated
        return f(*args, **kwds)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/solve.py", line 415, in _collect_all_metadata
        index, r = self._prepare(prepared_specs)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/solve.py", line 1011, in _prepare
        self.subdirs, prepared_specs, self._repodata_fn)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 228, in get_reduced_index
        repodata_fn=repodata_fn)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 105, in query_all
        result = tuple(concat(executor.map(subdir_query, channel_urls)))
      File "/home/hom/Softwares/miniconda3/lib/python3.6/concurrent/futures/_base.py", line 586, in result_iterator
        yield fs.pop().result()
      File "/home/hom/Softwares/miniconda3/lib/python3.6/concurrent/futures/_base.py", line 425, in result
        return self.__get_result()
      File "/home/hom/Softwares/miniconda3/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
        raise self._exception
      File "/home/hom/Softwares/miniconda3/lib/python3.6/concurrent/futures/thread.py", line 56, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 98, in 
        package_ref_or_match_spec))
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 110, in query
        self.load()
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 174, in load
        _internal_state = self._load()
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 255, in _load
        return self._load()
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 263, in _load
        mod_etag_headers.get('_mod'))
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 311, in _read_local_repdata
        _internal_state = self._process_raw_repodata_str(raw_repodata_str)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 349, in _process_raw_repodata_str
        json_obj = json.loads(raw_repodata_str or '{}')
      File "/home/hom/Softwares/miniconda3/lib/python3.6/json/__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "/home/hom/Softwares/miniconda3/lib/python3.6/json/decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/home/hom/Softwares/miniconda3/lib/python3.6/json/decoder.py", line 355, in raw_decode
        obj, end = self.scan_once(s, idx)
    json.decoder.JSONDecodeError: Unterminated string starting at: line 184947 column 5 (char 5586731)

# 这里省去一堆本地参数

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

If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?

[y/N]:
Timeout reached. No report sent.

你可能感兴趣的:(Conda无法安装或更新的问题)