其他
conda 安装软件报错
conda 安装软件报错
conda 隔一段时间不用,再打开安装什么软件时经常性的会无缘无故报错,最近需要安装总是有问题。
$ conda install python=2
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): failed
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/root/miniconda3/lib/python3.9/site-packages/conda/core/subdir_data.py", line 371, in _load
raw_repodata_str = fetch_repodata_remote_request(
File "/root/miniconda3/lib/python3.9/site-packages/conda/core/subdir_data.py", line 808, in fetch_repodata_remote_request
raise Response304ContentUnchanged()
conda.core.subdir_data.Response304ContentUnchanged
... # 中间内容太多省略
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]: n
No report sent. To permanently opt-out, use
$ conda config --set report_errors false
根据报错经验,很可能又是镜像源有问题了,有时候能安装上,但是总有几个大点的包会安装失败,那可能是网速问题,可以用手机 开个热点 试试。网上搜了好几个解决方法,终于找到一个能解决的!
那就是把你的 condarc 文件里的镜像源
全部换掉。
# 切换到root目录
$ cd
$ pwd
/root
# 查看当前内容,condarc文件是隐藏文件
$ ls -la
drwx------ 17 root root 4096 Jun 27 15:09 .
drwxr-xr-x 19 root root 4096 Jun 27 14:41 ..
-rw------- 1 root root 61 Apr 26 19:15 .Xauthority
-rw------- 1 root root 47424 Jun 27 14:43 .bash_history
-rw-r--r-- 1 root root 3718 Jun 27 14:45 .bashrc
drwxr-xr-x 6 root root 4096 Apr 26 21:08 .cache
drwxr-xr-x 2 root root 4096 Mar 7 22:15 .conda
-rw-r--r-- 1 root root 821 Jun 27 15:09 .condarc
drwxr-xr-x 6 root root 4096 Apr 3 16:10 .config
drwxr-xr-x 6 root root 4096 Mar 16 14:18 .cpan
找到了 condarc 文件后用 vi 编辑器打开修改为以下内容:
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
参考自:【报错】Anaconda Collecting package metadata (repodata.json): failed[1]
$ vi .condarc
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
然后保存退出,重新安装软件试一下:
conda install python=2
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /root/miniconda3/envs/py2
added / updated specs:
- python=2
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2021.5.25 | h06a4308_1 112 KB defaults
certifi-2020.6.20 | pyhd3eb1b0_3 155 KB defaults
openssl-1.1.1k | h27cfd23_0 2.5 MB defaults
python-2.7.18 | h02575d3_0 9.8 MB defaults
------------------------------------------------------------
Total: 12.6 MB
...
Downloading and Extracting Packages
python-2.7.18 | 9.8 MB | ################################################################################################################### | 100%
openssl-1.1.1k | 2.5 MB | ################################################################################################################### | 100%
ca-certificates-2021 | 112 KB | ################################################################################################################### | 100%
certifi-2020.6.20 | 155 KB | ################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
$
搞定!
参考资料
【报错】Anaconda Collecting package metadata (repodata.json): failed: https://blog.csdn.net/xiangduixuexi/article/details/108831726
欢迎小伙伴留言评论!
今天的分享就到这里了,敬请期待下一篇!
最后欢迎大家分享转发,您的点赞是对我的鼓励和肯定!
如果觉得对您帮助很大,打赏一下吧!