pysam-developers / pysam

Pysam is a Python package for reading, manipulating, and writing genomics data such as SAM/BAM/CRAM and VCF/BCF files. It's a lightweight wrapper of the HTSlib API, the same one that powers samtools, bcftools, and tabix.
https://pysam.readthedocs.io/en/latest/
MIT License
773 stars 274 forks source link

ModuleNotFoundError when using pysam in conda environment #1282

Closed ayushm64 closed 4 months ago

ayushm64 commented 4 months ago

I am running a snakemake workflow from this github repo the workflow runs in two conda environments. One of the two environments requires pysam as a dependency, but when I ran the workflow I received a ModuleNotFoundError for pysam and when I ran conda list within the environment I saw that pysam was not installed. After manually activating the conda environment and installing pysam 0.20.0 (the version the repo was tested with), I ran the workflow again and I still receive the same error. This is despite verifying that pysam is now in the environment using conda list while the environment is activated. Here is the terminal output when I manually activate the environment and explicitly execute the problematic script:

(/home/ayush/evo-genome-analysis/.snakemake/conda/e7058f7e8daa0d39e1ca146fe09d6f2d_) ayush@DESKTOP-45HGJK1:~/evo-genome-analysis$ python3 scripts/pileup/extract_nonprimary.py             --bam test_data/output/mapped_reads/RefWT113017-W/E8G_trimmed_WTRef_bow_sorted_collated.bam --csv test_data/output/pileup/RefWT113017-W/non_primary/E8G_trimmed_WTRef_bow_sorted_collated/non_primary.csv

Traceback (most recent call last):
  File "/home/ayush/evo-genome-analysis/scripts/pileup/extract_nonprimary.py", line 1, in <module>
    import pysam
ModuleNotFoundError: No module named 'pysam'

What could be the cause of this? Please let me know if I need to provide any additional information. Thank you!

ErikaKvalem commented 4 months ago

I have the same issue. The pysam version installed: pysam 0.21.0 py36h50b03f4_0 bioconda

jmarshall commented 4 months ago

What version of python is being run? Probably this is #1202, which is a bioconda issue.

ayushm64 commented 4 months ago

Yes I was using python 3.11. I switched to python 3.10 in the environment and the issue seems to be resolved. Thank you!