anaconda3 | 使用中常见错误
该篇在conda的常见错误中,非常有参考价值,为防止将来该网页信息丢失,将其copy记录下来,其原文链接等如下:
作者:生信师姐
原文链接:https://www.jianshu.com/p/4c7b9127cf83
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
1. conda安装环境报错:Solving environment: failed with initial frozen solve.
$conda install -c bioconda hypo 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.
方案1:
首先,把你安装的anaconda卸了重装,反正我是这么干的,强迫症患者,这样干净
更新conda到最新版本:conda update -n base conda
再查一下conda版本:conda -V
并不是最新版本conda 4.7.11
第二次更新conda到最新版本:conda update -n base conda
第二次很重要!!!而且,这次它读环境的时候贼慢,我以为我电脑卡死机了呢,半年不动弹,等着就行了
更新完后再查一下conda版本:conda -V,发现是最新版本conda 4.7.11
然后执行:conda update --all
然后,装啥啥好使,整啥啥好使,啥啥都好使,好使就完事了!!!!!!
方案2:
# 更新conda conda update -n base conda conda update -all # 修改频道 conda config --add channels conda-forge conda config --set channel_priority flexible # 重新尝试
2. conda安装库时报错Solving environment: failed with initial frozen solve. Retrying with flexible solve.
conda安装库时报错:
发现原因
后来查看错误信息的时候发现,原来是为了使用conda-forge的两条命令导致此错误。罪魁祸首是第二句。
conda config --add channels conda-forge conda config --set channel_priority strict
解决方法:
conda config --add channels conda-forge conda config --set channel_priority flexible
评论:我在本次conda环境安装中踩得最大坑
3. conda install遇到Segmentation fault错误
出错原因:可能是之前安装的时候网络不好导致中途中断,这个包只下载了一部分,但是并不完整。因此需要把之前下载的压缩包删除,再进行安装。
解决方案1:通过conda clean进行清理。
conda clean -a 删除所有包all,缓存 -i,锁定文件,无用缓存-p,tar包-t conda clean -i 删除缓存index cache conda clean -p 删除未使用的缓存。 conda clean -t 删除缓存tar包 conda clean -f 删除所有可写的程序包缓存,此项不包含在-a命令中 conda clean -c 删除由于正在使用而无法删除的临时文件
conda clean -a
删除所有的缓存。
进入anaconda/pkgs 找到下载的不完整的压缩包,删除即可
解决方案2:在base环境中执行以下命令,清除缓存位置(…/anaconda3/pkgs/)中未下载完的文件。
在anaconda/pkgs 找到下载的不完整的压缩包,然后删除,再conda install这个包就没问题了
4. 使用conda命令安装时报错:CondaHTTPError
(1)方案1:亲测可用
$conda install anaconda-clean Collecting package metadata (current_repodata.json): failed CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.ustc.edu.cn/anaconda/pkgs/free/linux-64/repodata.json> Elapsed: - An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way. 'https://mirrors.ustc.edu.cn/anaconda/pkgs/free/linux-64'
channels问题,个人认为比较快的解决方式是运行以下命令:把镜像里面的,https改为http
conda config --remove-key channels #删除所有的channels,没运行通 #添加清华镜像源 conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ conda config --set show_channel_urls yes # 搜索时显示通道地址 #或者中科大镜像 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/linux-64 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes
这次再安装bioconda 和 conda-forge是镜像
conda install -c bioconda module conda install -c conda-forge module
(2)方案2
换源吧:
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
(3)方案3(亲测可用)
打开.condarc文件,更改为如下:
vim ~/.condarc channels: - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/ - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ show_channel_urls: true ssl_verify: false
############私货#############
linux可执行文件添加到PATH环境变量的方法
https://www.cnblogs.com/joshua317/p/6899057.html
#vim里编辑文字:直接输入是没反应的。 #按一下a,就能输入了 #编辑完了之后按esc 然后按冒号 输入wq 回车
(4)方案4
#首先先添加清华的镜像源 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes #如果无法解决,则删除channels配置文件中部分内容 #具体操作如下: #1、快速创建channels配置文件的备份(保险起见) cp ~/.condarc{,.bak} #查看配置文件的内容 cat ~/.condarc.bak channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ - https://nanomirrors.tuna.tsinghua.edu.cn/anaconda/cloud - defaults - https://nanomirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda - https://nanomirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/conda - bioconda - r - conda-forge show_channel_urls: true #2、删除部分内容 ## 主要是删除此行: - defaults #修改后配置文件的内容如下: vim ~/.condarc channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ show_channel_urls: true
5. 使用conda命令安装时报错:('Connection broken: OSError("(104, 'ECONNRESET')")', OSError("(104, 'ECONNRESET')"))
$conda install -c bioconda kmc Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: /home/liuliu/software/anaconda3 added / updated specs: - kmc The following packages will be downloaded: package | build ---------------------------|----------------- conda-4.8.3 | py37_0 2.8 MB kmc-3.1.2rc1 | h2d02072_0 13.1 MB bioconda ------------------------------------------------------------ Total: 15.9 MB The following NEW packages will be INSTALLED: kmc bioconda/linux-64::kmc-3.1.2rc1-h2d02072_0 The following packages will be UPDATED: conda 4.8.2-py37_0 --> 4.8.3-py37_0 Proceed ([y]/n)? y Downloading and Extracting Packages conda-4.8.3 | 2.8 MB | ################################################################################################################################################################ | 100% kmc-3.1.2rc1 | 13.1 MB | ##################################################9 | 32% ('Connection broken: OSError("(104, \'ECONNRESET\')")', OSError("(104, 'ECONNRESET')"))
发生场景:在Ubuntu,使用Anaconda安装一些包。
这种问题大概就是下载国外的包什么的网速太慢了,下载失败。
解决办法:
用国内的镜像算了。这里我用的清华大学的一个镜像开源下的:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
在终端直接复制粘贴:
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes
再使用conda install安装你想装的包吧
6. CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'
首次使用 source activate 命令激活虚拟环境
source activate R3.6 # 退出虚拟环境 conda deactivate
否则会报下面的错
7. PackagesNotFoundError: The following packages are not available from current channels
解决办法:将conda-forge添加到搜索路径上
首先,当出现这种报错时,应该首先尝试使用以下命令将conda-forge channel添加到你的channel列表中:
conda config --append channels conda-forge
它告诉conda在搜索软件包时也要在conda-forge channel上查看。
然后你就可以尝试利用如下命令再次安装
conda install
包名
原因在于:channel可以看成是托管python包的服务器,当无法通过标准channel获得python包时,社区驱动的conda-forge通常是一个很好的地点。大部分问题都可以利用这条语句解决。
8. Collecting package metadata (current_repodata.json): failed
Collecting package metadata (current_repodata.json): failed CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/linux-64/current_repodata.json> Elapsed: - An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way. If your current network has https://www.anaconda.com blocked, please file a support request with your network engineering team. 'https//repo.anaconda.com/pkgs/main/linux-64'
解决办法:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
https://www.csdn.net/gather_2b/MtTakgysMjczODEtYmxvZwO0O0OO0O0O.html
9 conda安装软件报兼容性问题的解决 Found conflicts! Looking for incompatible packages.failed.UnsatisfiableError
尝试对conda更新以解决兼容性问题
conda update --all conda update conda
还是不行,报错如下
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): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: \ Found conflicts! Looking for incompatible packages. failed UnsatisfiableError: The following specifications were found to be incompatible with each other: Output in format: Requested package -> Available versionsThe following specifications were found to be incompatible with your system: - feature:/linux-64::__glibc==2.31=0 - feature:|@/linux-64::__glibc==2.31=0 - **A程序** -> libgcc-ng[version='>=9.3.0'] -> __glibc[version='>=2.17'] Your installed version is: 2.31
添加国内镜像
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/ conda config --add channels http://mirrors.aliyun.com/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
再进行安装,成功。
10. conda 尝试解决冲突但失败了。
为什么都已经创建新的环境了,conda 安装软件还是报错.
conda create -n merqury.1.3 conda activate merqury.1.3 conda install -c bioconda merqury Collecting package metadata (current_repodata.json): done Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve. Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source. Collecting package metadata (repodata.json): done Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve. Solving environment: - Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. failed UnsatisfiableError:
这个错误可能是由一个或多个包之间的版本冲突导致的,conda尝试解决冲突但失败了。以下是一些可能的解决方案:
(1)使用mamba代替conda:Mamba是一个由conda社区开发的,与conda兼容的包管理器。它在处理包依赖关系及冲突问题时,通常会比conda更有优势。
执行以下命令安装mamba:
conda install mamba -n base -c conda-forge
使用mamba安装Merqury:
mamba install -c bioconda merqury
(2)更新conda:有时候,这个问题可能是由于conda版本过旧引起的。你可以执行 conda update conda 来尝试更新conda。
(3)指定包版本:你可以尝试以特定版本安装包。例如,如果你想安装merqury的1.3版,你可以使用
conda install -c bioconda merqury=1.3
不过在尝试这些解决方案之前,请记住在尝试安装任何包之前先激活你的环境。此外,你可能也需要确保你的Bioconda频道设置正确。你可以通过运行 conda config --show channels 来查看你目前的频道设置。如果你没有看到bioconda,你可以使用 conda config --add channels bioconda 来添加。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了