How to Install `pairtools` Properly in Python 3.12
If you're trying to install pairtools—a toolkit for parsing, sorting, and analyzing Hi-C paired-end sequencing data—but run into linking issues with pysam, you're not alone. A common and frustrating issue is this: ImportError: libchtslib.cpython-312-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory Even after using --no-build-isolation, you might still see errors like: /tmp/pip-build-env-*/overlay/lib/python3.12/site-packages/pysam/libchtslib.cpython-312-x86_64-linux-gnu.so => not found This happens because the compiled shared object is wrongly linked to temporary build paths. In this guide, I'll show you how to fix this for good. ✅ Goal To install pairtools in an isolated environment (like GitHub Codespaces), ensuring that: pysam is installed from source. Shared libraries are not linked to /tmp or other temporary build paths. All 17 tests pass using pytest.

If you're trying to install pairtools
—a toolkit for parsing, sorting, and analyzing Hi-C paired-end sequencing data—but run into linking issues with pysam
, you're not alone.
A common and frustrating issue is this:
ImportError: libchtslib.cpython-312-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory
Even after using --no-build-isolation
, you might still see errors like:
/tmp/pip-build-env-*/overlay/lib/python3.12/site-packages/pysam/libchtslib.cpython-312-x86_64-linux-gnu.so => not found
This happens because the compiled shared object is wrongly linked to temporary build paths. In this guide, I'll show you how to fix this for good.
✅ Goal
To install pairtools
in an isolated environment (like GitHub Codespaces), ensuring that:
-
pysam
is installed from source. - Shared libraries are not linked to
/tmp
or other temporary build paths. - All 17 tests pass using
pytest
.