BUG:
事情发生的原因:
由于使用的linux机器和GLIBC版本较老,导致使用conda安装trim-galore时出现了以下报错:
[xxx@xxx bin]$ conda install trim-galore
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.17=0
- python=3.9 -> libgcc-ng[version='>=11.2.0'] -> __glibc[version='>=2.17']
Your installed version is: 2.17
系统版本和GLIBC版本
# uname -a
Linux 01 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64
# ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
解决方案
错误分析
错误表明是__glibc(GNU C库)的版本冲突,系统上安装的是2.17,而某些软件包需要更高版本的__glibc(例如>=2.17或更高)。
故可以尝试以下方案:
- 升级GLIBC版本
- 降级python版本
- 可以尝试用pip或者手动安装等方式
- 第三种方式偶然见看到,最终解决也是使用的这种方式
尝试方案一 升级GLIBC
升级的代码如下:
wget http://ftp.gnu.org/gnu/libc/glibc-2.28.tar.gz
tar -xvzf glibc-2.28.tar.gz
cd glibc-2.28
mkdir build
cd build
../configure --prefix=/opt/glibc-2.28
make -j$(nproc)
sudo make install
export LD_LIBRARY_PATH=/opt/glibc-2.28/lib:$LD_LIBRARY_PATH
但是由于系统比较老吧,在检测环境和配置时(…/configure)出现以下报错:
···
checking if gcc is sufficient to build libc... yes
checking for nm... nm
checking for python3... python3
configure: error:
*** These critical programs are missing or too old: make
*** Check the INSTALL file for required versions.
报错显示make工具版本过旧,那接着升级make吧
wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz
tar -xvzf make-4.3.tar.gz
cd make-4.3
./configure
make
sudo make install
成功将make版本升级:GNU Make 3.82 ——> GNU Make 4.3
但是我又返回升级glibc时仍然报错:
These critical programs are missing or too old: make
Check the INSTALL file for required versions.
遂懒得再弄了。
尝试方案二 降级python版本
没有尝试,有兴趣的小伙伴自行尝试
尝试方案三 pip等其他方式安装
据我所知,conda对包的管理更加严格,所以很多情况下,conda安装不了的包使用pip可以轻松安装。当然pip毕竟只是针对于python包的管理工具,而conda范围更广,可以适用于R、C++等包的安装。
如果你下载的包无法用pip安装(比如trim-galore),可以考虑使用其他的手动安装方式。
在这里我也没有尝试这种方式,有兴趣的小伙伴自行尝试。
尝试方案四 可能是channel的问题
启发我的原文:conda-glibc-dependency-conflict
原文是这么说的:
I strongly suspect that the issue was caused by a mixture of packages from conda-forge and Anaconda default channels in the same environment. According to conda developers, this is considered a bad practice. Once I have changed it around to using conda-forge only, the problems went away.
我的condarc配置如下:
channels:
- https://conda.anaconda.org/IBMDecisionOptimization/linux-64
- http://conda.anaconda.org/dranew
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- 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
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
最终使用下面一行代码,就成功安装了。
conda install -c conda-forge trim-galore
思考
conda使用不同的源(defaults和conda-forge等)来提供不同的包,而这些包可能具有不同的版本、依赖关系和构建方式。混合使用多个通道可能会导致以下问题:
- 版本不一致:有时同一个包在不同的通道中会有不同的版本号,可能会导致依赖关系的不匹配。
- 编译选项不同:某些包可能在不同的源上采用了不同的编译选项,导致兼容性问题。
- 优先级问题:conda默认按照配置文件中列出的顺序优先安装包,如果通道顺序不当,conda可能会安装不兼容的版本。
conda的开发者强烈建议不要混合使用多个通道,尤其是defaults和conda-forge,因为这可能会导致版本冲突和依赖问题。所以我后续修改了condarc的文件:
channels:
- conda-forge
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
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
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud