处理conda安装工具的动态库问题——解决记录

问题记录

在conda的某工作环境下使用rmats2rmats2sashimiplot作图的时候,发现有一个报错:无法找到libcrypto.so.1.0.0,我查看了游一下samtools的依赖

$ldd `which samtools`
    linux-vdso.so.1 =>  (0x00007fff96dfe000)
    libm.so.6 => /lib64/libm.so.6 (0x00007fc22ef22000)
    libz.so.1 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/libz.so.1 (0x00007fc22ed09000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007fc22eb05000)
    libcrypto.so.1.0.0 => not found
    libcurl.so.4 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/libcurl.so.4 (0x00007fc22ea7c000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc22e860000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fc22e493000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fc22f24b000)
    libssh2.so.1 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/./libssh2.so.1 (0x00007fc22e45f000)
    libssl.so.1.1 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/./libssl.so.1.1 (0x00007fc22e3c9000)
    libcrypto.so.1.1 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/./libcrypto.so.1.1 (0x00007fc22e0d1000)
    libgssapi_krb5.so.2 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/./libgssapi_krb5.so.2 (0x00007fc22e081000)
    libkrb5.so.3 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/./libkrb5.so.3 (0x00007fc22dfa5000)
    libk5crypto.so.3 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/./libk5crypto.so.3 (0x00007fc22df86000)
    libcom_err.so.3 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/./libcom_err.so.3 (0x00007fc22df7f000)
    librt.so.1 => /lib64/librt.so.1 (0x00007fc22dd77000)
    libkrb5support.so.0 => /home/sxj/biosoft/anaconda/envs/dss/bin/../lib/././libkrb5support.so.0 (0x00007fc22dd67000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fc22db4e000)

我们可以看到libcrypto.so.1.0.0 => not found,检索的时候发现洲更之前的简书提到过类似的问题如何用conda安装软件|处理conda安装工具的动态库问题,解决的办法不外乎:

  • 更新降级或者重新安装
  • 安装对应版本的libcrypto.so.1.0.0

解决记录一

首先我们来查看一下洲更解决的办法, 即检查conda的安装镜像的优先级:

$cat .condarc
ssl_verify: false
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true

这里我看了一下,我的镜像的优先级不对,GitHub上有几个issue专门针对这个问题作出了解答,入下:

samtools 1.9 dependency pulls in wrong version of openssl #12100

OpenSSL migration

但是我们这里看了一下我的openssl的安装来源:

$conda list
openssl                   1.1.1b               h14c3975_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge

镜像没问题啊,我重新安装了以后发现问题也没有解决。

这时候有个老哥的评论引起了我的注意:

This is because the samtools 1.9 depends on openssl 1.0.x (I hope the next version will support or just change the shared library name) and openssl 1.1.x was installed,if you must keep the openssl 1.1.x version, a possible solution is :
1. move to the /*Your_Path_of_conda/lib (for me ~/anaconda3/lib/) folder
2. give a soft link of "libcrypto.so.1.1" named "libcrypto.so.1.0.0" to cheat on the samtools

这个操作骚啊,下面有11个👍,还有一个✈,看得我头皮发麻,不用考虑就知道这个没问题。

ls /home/sxj/biosoft/anaconda/envs/ROSE_ngsplot/bin/../lib/libcry*
/home/sxj/biosoft/anaconda/envs/ROSE_ngsplot/bin/../lib/libcrypto.a  /home/sxj/biosoft/anaconda/envs/ROSE_ngsplot/bin/../lib/libcrypto.so  /home/sxj/biosoft/anaconda/envs/ROSE_ngsplot/bin/../lib/libcrypto.so.1.1
ln /home/sxj/biosoft/anaconda/envs/ROSE_ngsplot/bin/../lib/libcrypto.so.1.1 /home/sxj/biosoft/anaconda/envs/ROSE_ngsplot/bin/../lib/libcrypto.so.1.0.0

问题解决

按照这个思路,我又在另外一个环境里面发现了libcrypto.so.1.0.0,

$ldd `which samtools`
    linux-vdso.so.1 =>  (0x00007fffbe7fe000)
    libz.so.1 => /home/sxj/biosoft/anaconda/bin/../lib/libz.so.1 (0x00007f142c7f2000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f142c4c9000)
    libbz2.so.1.0 => /home/sxj/biosoft/anaconda/bin/../lib/libbz2.so.1.0 (0x00007f142c2b7000)
    liblzma.so.5 => /home/sxj/biosoft/anaconda/bin/../lib/liblzma.so.5 (0x00007f142c084000)
    libcurl.so.4 => /home/sxj/biosoft/anaconda/bin/../lib/libcurl.so.4 (0x00007f142be07000)
    libcrypto.so.1.0.0 => /home/sxj/biosoft/anaconda/bin/../lib/libcrypto.so.1.0.0 (0x00007f142b9b6000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f142b79a000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f142b3cc000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f142ca0b000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f142b1c4000)
    libssh2.so.1 => /home/sxj/biosoft/anaconda/bin/../lib/./libssh2.so.1 (0x00007f142af94000)
    libssl.so.1.0.0 => /home/sxj/biosoft/anaconda/bin/../lib/./libssl.so.1.0.0 (0x00007f142ad1b000)
    libgssapi_krb5.so.2 => /home/sxj/biosoft/anaconda/bin/../lib/./libgssapi_krb5.so.2 (0x00007f142aad2000)
    libkrb5.so.3 => /home/sxj/biosoft/anaconda/bin/../lib/./libkrb5.so.3 (0x00007f142a805000)
    libk5crypto.so.3 => /home/sxj/biosoft/anaconda/bin/../lib/./libk5crypto.so.3 (0x00007f142a5d6000)
    libcom_err.so.3 => /home/sxj/biosoft/anaconda/bin/../lib/./libcom_err.so.3 (0x00007f142a3d3000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f142a1ce000)
    libkrb5support.so.0 => /home/sxj/biosoft/anaconda/bin/../lib/././libkrb5support.so.0 (0x00007f1429fc3000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f1429da9000)

同样可以通过软链的方式解决了问题。

解决记录二

conda install -c bioconda samtools openssl=1.0

问题解决

推荐阅读更多精彩内容