解决conda中"requests.exceptions.HTTPError: 404 Client Error"问题
1. Question
bash
conda activate base
conda create -n myenv python=3.9
报错信息如下:
>>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/home/username/anaconda3/lib/python3.9/site-packages/conda/core/subdir_data.py", line 531, in fetch_repodata_remote_request
resp.raise_for_status()
File "/home//username/anaconda3/lib/python3.9/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:
2. 解决办法
出现该错误的原因是因为conda channels 有问题,可以追溯到~/.condarc
文件的设置。
解决方法参考自Conda update error: CondaHTTPError: HTTP 404 NOT FOUND #7695
最简单粗暴的方式就是删除原来乱七八糟的channels,恢复出厂默认设置。再次尝试看看。
注:可以在删除之前先备份一下~/.condarc
文件。
bash
conda config --remove-key channels
conda config --append channels conda-forge
再次使用conda时运行成功。