bxlab / metaWRAP

MetaWRAP - a flexible pipeline for genome-resolved metagenomic data analysis
MIT License
394 stars 190 forks source link

Importerror No module named Bio #470

Open saras224 opened 2 years ago

saras224 commented 2 years ago

Hi @jxtx I have installed metawrap version 1.3 but when I am running the bin refinement module its giving an error.

Error:

There are three bin folders, so there 4 ways we can refine the bins (A+B, B+C, A+C, A+B+C). Will try all four in parallel!

Traceback (most recent call last): File "/home/saraswati/conda/anaconda3/bin/metawrap-scripts/binning_refiner.py", line 37, in from Bio import SeqIO ImportError: No module named Bio Traceback (most recent call last): File "/home/saraswati/conda/anaconda3/bin/metawrap-scripts/binning_refiner.py", line 37, in from Bio import SeqIO ImportError: No module named Bio Traceback (most recent call last): File "/home/saraswati/conda/anaconda3/bin/metawrap-scripts/binning_refiner.py", line 37, in from Bio import SeqIO ImportError: No module named Bio Traceback (most recent call last): File "/home/saraswati/conda/anaconda3/bin/metawrap-scripts/binning_refiner.py", line 37, in from Bio import SeqIO ImportError: No module named Bio ls: cannot access Refined_AB/Refined: No such file or directory

Can you help me resolving this error? I already tried installing the biopython but that is not working.

Thanks

ursky commented 2 years ago

Run pip install biopython.

Nephilim94 commented 1 year ago

I also facing the same issue.......running pip install biopython not worked for me

YeGuoZJU commented 1 year ago

pip install biopython

I also facing the same issue.......running pip install biopython not worked for me.what can I do? thanks

YeGuoZJU commented 1 year ago

Hi @jxtx I have installed metawrap version 1.3 but when I am running the bin refinement module its giving an error.

Error:

There are three bin folders, so there 4 ways we can refine the bins (A+B, B+C, A+C, A+B+C). Will try all four in parallel!

Traceback (most recent call last): File "/home/saraswati/conda/anaconda3/bin/metawrap-scripts/binning_refiner.py", line 37, in from Bio import SeqIO ImportError: No module named Bio Traceback (most recent call last): File "/home/saraswati/conda/anaconda3/bin/metawrap-scripts/binning_refiner.py", line 37, in from Bio import SeqIO ImportError: No module named Bio Traceback (most recent call last): File "/home/saraswati/conda/anaconda3/bin/metawrap-scripts/binning_refiner.py", line 37, in from Bio import SeqIO ImportError: No module named Bio Traceback (most recent call last): File "/home/saraswati/conda/anaconda3/bin/metawrap-scripts/binning_refiner.py", line 37, in from Bio import SeqIO ImportError: No module named Bio ls: cannot access Refined_AB/Refined: No such file or directory

Can you help me resolving this error? I already tried installing the biopython but that is not working.

Thanks

Have you solve it?

mehmetday commented 1 year ago

I am having the same problem. Any response?

utkinaira commented 10 months ago

I am experiencing the same issue. Did anyone manage to solve this problem?

mojingmj123 commented 10 months ago

I have solved this problem by changing the "python2.7" in the shebang line of the binning_refiner.py file (~/metawrap/bin/metawrap-scripts/binning_refiner.py) to "python3.8". You can run "python3 --version" in the metawrap environment to check the supported python3 version number.

scottdossantos commented 7 months ago

On the off-chance that anyone is still running into these errors, I ran into them myself today (14th March 2024) and was able to fix them. Because this seems like a fairly common error, I'll give a verbose walkthrough of what I did, but TLDR is this:

check that biopython is actually installed in your conda environment and double check that the shebang lines of the offending script actually matches the version of python you have installed! (Credit to @mojingmj123 for that)

First of all, I cloned this git repository and added the 'bin' directory to my PATH in my .bashrc file. I'm running metawrap modules individually, using separate conda environments for each module, as I was unable to get all the required tools installed in a single environment (I saw the author give this advice in another git issue- I can't find the link, but I swear I saw it!). To make these environments, I used dependencies.md in this repo as a guide for which tools to install in each environment. I currently have separate environments for metawrap assembly, metawrap binning and metawrap bin_refinement. I tried for several hours to get CONCOCT working in the metawrap binning module, but kept running into the well-described 'OpenBLAS' issue, so gave up and settled for using MetaBAT2 and Maxbin2.

Assembling and binning the contigs went smoothly, but when I ran the bin_refinement module, I ran into the ImportError: No module named Bio issue described in this thread. I followed the advice of @mojingmj123 and changed the shebang line of binning_refiner.py from #!/usr/bin/env python2.7 to #!/usr/bin/env python3.10 to reflect my environment. While I'm sure this certainly helps, it didn't actually resolve my problem and I was still getting the error. However, my problem was entirely self-inflicted: I realised that in 'dependencies.md', biopython is NOT listed as a requirement for the bin refinement module, but as it turns out, it is absolutely needed. Installing it with mamba install biopython fixed the "ImportError" completely (who'd have thought!?).

After re-running metawrap bin_refinement, I noticed a few additional errors in the output which, although they didn't stop the binning, annoyed me enough to look into them. The first was two errors after the announcement "CONSOLIDATING ALL BIN SETS BY CHOOSING THE BEST VERSION OF EACH BIN", which were:

rm: cannot remove 'binsM': No such file or directory rm: cannot remove 'binsM.stats': No such file or directory

I think this is an 'if' statement gone wrong somewhere in bin_refinement.sh. The binsM directory and binsM.stats file exist after finishing the refinement module, so I don't think this one matters. The second (and related third) error was thrown just after CheckM finishes running on the refined bins, after the announcement "making completion and contamination ranking plots for all refinement iterations":

Traceback (most recent call last): File "/home/dossantos/tools/metaWRAP/bin/metawrap-scripts/plot_binning_results.py", line 7, in <module> import matplotlib.pyplot as plt ImportError: No module named matplotlib.pyplot

and

mv: cannot stat 'binning_results.eps': No such file or directory mv: cannot stat 'binning_results.png': No such file or directory

I checked to see if I had matplotlib installed and it was definitely there (matplotlib-base, but still works!). Again, checking the offening file, plot_binning_results.py showed that the shebang line once again read #!/usr/bin/env python2.7, so I changed it again. Boom, bin refinement module now working!

Lastly, don't worry about the error mv: cannot stat 'binning_results.eps': No such file or directory. As far as I can tell, the plotting python script never actually makes a .eps version of this figure!