按下面的方式搭建环境,可以避开本页大部分报错。
| 做法 | 不这样做的后果 |
|---|---|
| conda 频道按 conda-forge 在前、bioconda 在后设置,并把 channel_priority 设为 strict。 | 会装到依赖旧版 OpenSSL 的 samtools,运行时报 libcrypto.so.1.0.0 找不到。 |
| 为生信工具新建独立的 conda 环境,不装在 base 环境里。 | 不同工具的依赖互相覆盖,安装时报 Package conflicts。 |
| Windows 上先装 WSL2(Windows 自带的 Linux 子系统),在里面安装 samtools。 | Windows 版 conda 里没有 samtools,安装时报 PackagesNotFoundError。 |
| 从源码编译前装齐 zlib、bzip2、xz、curl、ncurses 的开发包。 | configure 报 development files not found;为了跳过检查而禁用 bzip2 或 lzma,部分 CRAM 文件会无法读取。 |
| 不要按报错手动安装旧版系统库(例如 libssl1.0.0)。 | 问题只是被推迟,下一个依赖旧库的工具还会报同样的错。 |
按报错原文排错
按报错原文查找。每条写出原因、解决办法,以及处理后可能遇到的后续问题。
samtools: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
原因:conda 的频道顺序不对,装到了依赖旧版 OpenSSL 的 samtools。
怎么解决:卸载 samtools,把频道设为 conda-forge 在前、bioconda 在后并设 channel_priority strict,再重新安装。
可能遇到的后续问题:改了频道顺序后,环境里其他包可能也要跟着更新,必要时运行 conda update --all。
samtools: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
原因:装到了旧版 samtools(例如 1.2),它依赖旧版 ncurses。
怎么解决:运行 conda install "samtools>=1.10",版本条件外面的引号不能省。
PackagesNotFoundError: The following packages are not available from current channels: samtools
原因:bioconda 只提供 Linux 和 macOS 版本,Windows 版 conda 里没有 samtools。
怎么解决:安装 WSL2,在其中的 Linux 环境里用 conda 安装 samtools。
可能遇到的后续问题:在 WSL2 里还要重新安装 conda 和其他生信工具,数据也要放在 WSL2 能访问的位置。
dyld: Library not loaded: @rpath/libcrypto.1.0.0.dylib
原因:macOS 上装到了过旧的 samtools,它依赖已经不存在的旧版 OpenSSL。
怎么解决:指定新版本重装,例如 conda install samtools=1.15.1;Apple 芯片的 Mac 上这样仍不行时,改用 brew install samtools。
可能遇到的后续问题:用 Homebrew 装的 samtools 和 conda 环境里的其他工具分属两套环境,脚本里调用时要注意用的是哪一个。
bcftools: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
原因:conda 选中了旧版 bcftools(例如 1.8),它依赖旧版 OpenSSL。
怎么解决:指定 bcftools>=1.9 重新安装;也可以按频道顺序的方法修好后重装。
可能遇到的后续问题:用 conda install bcftools openssl=1.0 也能消除这条报错,但会把旧版 OpenSSL 带进环境,之后其他工具可能冲突。
bcftools does not exist (perhaps a typo or a missing channel).
原因:mamba 只在默认频道里查找,没有添加 bioconda。
怎么解决:添加 conda-forge 和 bioconda 两个频道后再安装。
Package conflicts for:(涉及 zlib、libstdcxx-ng、libgcc-ng、ncurses)
原因:当前环境里已有的 zlib、ncurses 等包和新版 samtools 要求的版本冲突。
怎么解决:新建一个干净的 conda 环境,只装 samtools 及其所需的工具。
可能遇到的后续问题:在旧环境里强行求解往往很慢,而且可能降级其他已经能用的工具。
zlib development files not found
原因:从源码编译时系统里没有 zlib 的开发包。
怎么解决:Debian 或 Ubuntu 上运行 sudo apt install zlib1g-dev,RHEL 或 CentOS 上安装 zlib-devel。
可能遇到的后续问题:装好 zlib 后,htslib 还会依次检查 bzip2、lzma、curl 等开发包,通常要一并补齐。
curses development files not found
原因:系统里没有 ncurses 的开发包,samtools 的 tview 子命令需要它。
怎么解决:安装 libncurses5-dev(Debian 或 Ubuntu)或 ncurses-devel(RHEL 或 CentOS);不需要 tview 时可以用 ./configure --without-curses。
HTSlib development files not found
原因:configure 找不到 htslib 的源码目录或已安装的 htslib。
怎么解决:用 ./configure --with-htslib=DIR 指定 htslib 的源码或安装目录。
可能遇到的后续问题:htslib 和 samtools 的版本要对应,混用不同版本时编译或运行会出错。
Scientify 是一台装好了科研软件、内置 Codex、Claude Code 等 AI Agent 的云电脑。你只需用一句话说明要做什么,例如「把这批 FASTQ 比对到这份参考基因组,排序、建索引,并统计比对率」,Agent 就会调用已装好的 samtools 自动完成建模和计算,不用安装软件,也不用写代码。
相比在你的电脑上继续装环境,云电脑里已经装好 samtools、bcftools 和 htslib 1.24,bwa、bowtie2、minimap2 和 FastQC 等常用工具也已装好,打开就能用,关掉本机电脑后任务也会继续运行。
云电脑配备了更高的算力,可以按需调用 CPU 和 GPU 集群,支持大规模科学计算。算力按实际使用的分钟数计费,不会造成浪费。
- 云电脑
- 4 核 · 8 GB
- 最高配置,用于数据处理和中小规模计算
- 可调用 GPU
- 96 GB 显存
- 单卡最高 RTX PRO 6000;另有 H800 80 GB,多卡最高 8 张 A10G
- 可调用 CPU
- 224 核 · 3 TB
- 最高规格,用于大规模并行计算
参考资料
- Biostars:用 conda 安装 samtools 的两个常见错误 — libcrypto.so.1.0.0 与 libncurses.so.5;samtools>=1.10 与频道顺序
- Biostars:Samtools fails with libcrypto error — 频道顺序与 channel_priority strict
- Biostars:Windows 上 conda install samtools 报 PackagesNotFoundError — PackagesNotFoundError,建议使用 WSL2
- Biostars:M1 Mac 上 samtools 报 libcrypto.1.0.0.dylib — samtools=1.15.1 与 brew install samtools
- Biostars:bcftools 的 libcrypto 报错 — openssl=1.0 的做法与频道顺序
- bioconda-recipes issue #21229 — bcftools 1.8 与 bcftools>=1.9
- samtools INSTALL — 各发行版需要的开发包与 configure 选项
- samtools configure.ac — zlib、curses 与 HTSlib 的报错原文
- htslib INSTALL — 禁用 bzip2、lzma 会导致部分 CRAM 无法读取