Help needed with Biopython and Spyder
0
0
Entering edit mode
5.1 years ago

Hi everyone! By writting this post I hope to be able to solve the problem that is driving me crazy!

I am trying to use Biopython using Spyder as IDE. I have installed Biopython in Linux Mint by using conda and also I have installed using pip. Everything seems okay, I tried in the terminal and in Spyder and it works. However, when I try to use the next order:

from Bio import SeqIO

Spyder terminal gives me the next answer:

Traceback (most recent call last):
  File "<ipython-input-2-5d24a7c49c42>", line 1, in <module>
    from Bio import SeqIO
  File "/home/andrea/Descargas/biopython-1.74/Bio/SeqIO/__init__.py", line 387, in <module>
    from Bio.Align import MultipleSeqAlignment
  File "/home/andrea/Descargas/biopython-1.74/Bio/Align/__init__.py", line 22, in <module>
    from Bio.Align import _aligners
ImportError: cannot import name '_aligners' from 'Bio.Align' (/home/andrea/Descargas/biopython-1.74/Bio/Align/__init__.py)*

I checked if in the terminal if this works and exactly, the terminal doesn't give me any error message. I checked if Python's version is the problem, but the terminal and Spyder are working in the same Python's version (3.7). I have also checked with other entries such as:

from Bio import Entrez

and it works in Spyder and in the terminal

Does anybody know what is happening here?

Thank you a lot!! :)

biopython spyder seqIO • 5.1k views
ADD COMMENT
0
Entering edit mode

Can a mod bump this to a question instead of a forum post?

Have you tried setting your environment variables appropriately? See https://stackoverflow.com/questions/11919615/how-to-change-the-path-of-python-in-spyder

ADD REPLY
0
Entering edit mode

Yes, I tried but I am not sure the PATH I have to put. I select the folder where I have biopython, but it still giving message errors.

Thank you!

ADD REPLY
0
Entering edit mode

Hi, I've seen this before but I don't recall the root cause. But from that you've posted I thing that you have 2 Pythons and 2 BioPythons installed. And you are trying to import BioPython A from "Python B".

Try (below) from both Python terminals and see which terminal points where

import sys
print(sys.executable)

Also use (below) to explore which conda environment holds your BioPython.

conda env list     # to list installed enviroments
conda list            # to list installed packages in conda environment

If you would like to use spyder with conda env, then this env must be avalible to Spyder. In Pycharm (which I use) there is special setting for executable PATH independent on environment variables, so maybe it might be similar in Spyder.

Do not mix conda and pip installations, both are package managers but do stuff differently.

I would suggest to make a clean install of everything with one of the package managers.

ADD REPLY
0
Entering edit mode

Thank you for your answer!!

I have done what you said, and this is what I get:

- In Spyder terminal: /home/andrea/anaconda3/bin/python

- In normal terminal: /home/andrea/anaconda3/bin/python

(I have uninstalled the Biopython that I installed by using pip) Now Biopython doesn't work in the terminal, and still working in Spyder. However when I write again the command:

from Bio import SeqIO

It still giving the same error message :(

What can I do now?

ADD REPLY
0
Entering edit mode

The /home/andrea/anaconda3/bin/python means that you are using conda python. And you should manage your python packages by conda not by pip. Now I think that You've installed Biopython with pip to conda env - this is not good idea (link attached at the end on combining conda and pip).

Since importing SeqIO gives you the error message I think that you either don't have biopython installed in your conda env (you didn't posted results from conda list) or that the installation is broken.

I would suggest to try to install the biopython from conda (below). If that fails, then remove anaconda completely and run clean install (this might be easier then trying to fix the installation).

First setup chanels for bioconda (https://bioconda.github.io/user/install.html#set-up-channels) if you haven't already.

Then run conda install biopython from shell terminal to install biopython. (Do not use pip.)

Then try to import what you want.

suggested reading when using conda and pip: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#pip-in-env

ADD REPLY
0
Entering edit mode

THANK YOU!! It worked!!! It was what you said, I didn't have biopython installed in conda env, but it was because I didn't setup channels for bioconda. Now everything works!

ADD REPLY

Login before adding your answer.

Traffic: 1800 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6