1 What is Conda?
Conda (Anaconda、Miniconda) 是一个功能强大、工具全面的包管理和环境管理工具(姑且可以理解为应用超市),其对于计算机技能没这么娴熟的生信工作者来说,是安装软件的一个福音。但是,他有一个最致命的缺点,就是「慢」!
生信工具很多都需要其他依赖,尤其是依赖包多起来的时候,用 conda 来安装软件可能过了一晚上还是只能看到一下几行代码在反复横跳......甚至很多时候直接 fail 掉
Collecting package metadata (current_repodata.json): doneSolving 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): doneSolving 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.......
2 What is Mamba?
Mamba 是一个开源的 Python 发行版本,是 Conda 的替代品,用法与 Conda 完全一致,但是速度比 Conda 快不是一点半点。
特别是在安装 BUSCO 这种依赖特别多,文件特别大的软件,优势就非常明显了
3 How to Install Mamba?
Mamba 有 2 种安装方法:
1. 直接用 Mambaforge/Miniforge 代替 Anaconda/Miniconda(官方推荐)
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh"bash Mambaforge-$(uname)-$(uname -m).sh#或者下载安装包进行本地 bash 安装:#https://github.com/conda-forge/miniforge
2. 在 Conda 的 base 环境安装 mamba(官方不推荐)
conda install -n base -c conda-forge mamba
对于第 1 种安装方法,需要将 conda 的命令都换成 mamba,例如:
mamba listmamba env listmamba create -n buscomamba install -c bioconda busco
对于用习惯了 conda 的人来说,切换可能不太自如,还是想用 conda 的命令,这时候很多人会选择第 2 种安装方式(me too.)
4 Troubleshooting While Using Mamba Under Conda's Environment
但是使用第 2 种方式安装经常会发生一个报错(Linux/MacOS):
#LinuxError while loading conda entry point: conda-libmamba-solver (/home/${USER}/miniconda3/lib/python3.11/site-packages/libmambapy/../../../libmamba.so.2: undefined symbol: archive_read_support_filter_zstd)#用户名用${USER}代替
报错内容提到:undefined symbol: archive_read_support_filter_zstd
意味缺少对 archive(压缩文档)的支持
一番折腾后,发现可能是缺少了 libarchive ,这是一个 C 库,用于处理压缩格式的文件如 tar、ZIP、7-Zip,这是 mamba 的其中一个依赖。
为了解决这个报错,可以先尝试安装这个库,如使用 conda 安装:
conda install -c conda-forge libarchive
conda 会安装相关内容:
## Package Plan ## environment location: /home/${USER}/miniconda3 added / updated specs: - libarchiveThe following packages will be downloaded: package | build ---------------------------|----------------- libarchive-3.6.2 | h3d51595_0 816 KB conda-forge lzo-2.10 | h516909a_1000 314 KB conda-forge ------------------------------------------------------------ Total: 1.1 MBThe following NEW packages will be INSTALLED: lzo conda-forge/linux-64::lzo-2.10-h516909a_1000 The following packages will be SUPERSEDED by a higher-priority channel: libarchive pkgs/main::libarchive-3.6.2-h6ac8c49_2 --> conda-forge::libarchive-3.6.2-h3d51595_0
安装完成后,尝试使用 conda 或者 mamba 看看是否还会发生报错,如:
conda --versionconda listconda env listmamba info...
如果没有出现报错,恭喜你,可以愉快使用 mamba 了!
但是对于 MacOS 的用户,报错往往依旧(me too...)
查看 libarchive 库已经是安装了的,但还是有报错:
#MacOSError while loading conda entry point: conda-libmamba-solver (dlopen(/Users/${USER}/miniconda3/lib/python3.11/site-packages/libmambapy/bindings.cpython-311-darwin.so, 0x0002): Library not loaded: @rpath/libarchive.13.dylib Referenced from: /Users/${USER}/miniconda3/lib/libmamba.2.0.0.dylib Reason: tried: '/Users/${USER}/miniconda3/lib/libarchive.13.dylib' (no such file), '/Users/${USER}/miniconda3/lib/python3.11/site-packages/libmambapy/../../../libarchive.13.dylib' (no such file), '/Users/${USER}/miniconda3/lib/python3.11/site-packages/libmambapy/../../../libarchive.13.dylib' (no such file), '/Users/${USER}/miniconda3/bin/../lib/libarchive.13.dylib' (no such file), '/Users/${USER}g/miniconda3/bin/../lib/libarchive.13.dylib' (no such file), '/usr/local/lib/libarchive.13.dylib' (no such file), '/usr/lib/libarchive.13.dylib' (no such file, not in dyld cache))WARNING conda.plugins.manager:load_entrypoints(114): Error while loading conda entry point: conda-libmamba-solver (dlopen(/Users/${USER}/miniconda3/lib/python3.11/site-packages/libmambapy/bindings.cpython-311-darwin.so, 0x0002): Library not loaded: @rpath/libarchive.13.dylib Referenced from: /Users/${USER}/miniconda3/lib/libmamba.2.0.0.dylib Reason: tried: '/Users/${USER}/miniconda3/lib/libarchive.13.dylib' (no such file), '/Users/${USER}/miniconda3/lib/python3.11/site-packages/libmambapy/../../../libarchive.13.dylib' (no such file), '/Users/${USER}/miniconda3/lib/python3.11/site-packages/libmambapy/../../../libarchive.13.dylib' (no such file), '/Users/${USER}/miniconda3/bin/../lib/libarchive.13.dylib' (no such file), '/Users/${USER}/miniconda3/bin/../lib/libarchive.13.dylib' (no such file), '/usr/local/lib/libarchive.13.dylib' (no such file), '/usr/lib/libarchive.13.dylib' (no such file, not in dyld cache))#用户名用${USER}代替
可以看到报错提示找不到文件:libarchive.13.dylib
这个文件是 MacOS 系统上 libarchive 库的动态链接库文件,在运行 mamba 的时候无法加载
于是在电脑上查找这个文件:
sudo find / -name libarchive.13.dylib -print#Result:/usr/local/Cellar/libarchive/3.7.1/lib/libarchive.13.dylib
将上述文件链接到报错中提到的缺失路径中:
ln -s /usr/local/Cellar/libarchive/3.7.1/lib/libarchive.13.dylib /Users/${USER}/miniconda3/lib/
链接成功后,mamba 的报错问题就解决了:
5 At the End
如果 Mac 找不到 libarchive 库,可以考虑现在本地安装后再链接过去,如使用 Homebrew 安装:
#Make sure you have Homebrew installed on your Mac!brew install libarchive
另外,Linux 的 libarchive 库的动态链接库与 MacOS 的不同,前缀是 libarchive.so
如果出现类似的报错,可以尝试使用链接的方法去解决。
来源地址:https://blog.csdn.net/Xylonwin/article/details/132724517