Conda無(wú)法安裝或更新的問(wèn)題

用conda安裝任何東西都報(bào)錯(cuò). 開(kāi)始懷疑是公司的鬼網(wǎng)絡(luò)問(wèn)題.

.condarc重命名, 重新嘗試, 一切又很正常, 以為是清華源TUNA的問(wèn)題, 還想去https://github.com/tuna/ 報(bào)錯(cuò).

后來(lái)一次將https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r channel一行在.condarc中刪掉后, 一切又正常了. 莫名其妙啊..

最開(kāi)始時(shí)懷疑是 raise UnavailableInvalidChannel(self.url_w_repodata_fn, 404)的問(wèn)題, 以為是清華源那邊缺失channeldata.json導(dǎo)致找不到subdir, 但關(guān)鍵的文件是repodata.json還是存在且一樣的. 可能不是TUNA的問(wèn)題.

于是重新仔細(xì)追查錯(cuò)誤, 發(fā)現(xiàn)這個(gè)錯(cuò)誤有三處:

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

第一個(gè)網(wǎng)絡(luò)是可以下載對(duì)應(yīng)repodata.json的, 第二個(gè)304重定向應(yīng)該不是, 第三個(gè)是json解碼的問(wèn)題. 搜了一下, 找到以下帖子:

JSONDecodeError with on-disk corrupted repodata #7190

噢, 原來(lái)還是公司網(wǎng)絡(luò)的鍋. 肯定是之前update repo信息時(shí)網(wǎng)絡(luò)有問(wèn)題, 于是就出現(xiàn)了污染.

解決辦法

conda clean -i

然后重新隨便install 個(gè)東西, 會(huì)重新下載repo信息. 問(wèn)題解決. NND的公司網(wǎng)絡(luò)...

附錯(cuò)誤內(nèi)容:

$ 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 <lambda>
        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)

# 這里省去一堆本地參數(shù)

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.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容