tebiwankenebi
tebiwankenebi

Reputation: 83

ModuleNotFoundError in Spyder

I tried to import the biopython package in Spyder and got the error message:

ModuleNotFoundError: No module named 'biopython' 

although biopython is installed.

I also checked the PYTHONPATH: there is a path set into the directory where the packages are stored.

Can somebody help? Did I miss something? Thanks for your help!

Upvotes: 2

Views: 19695

Answers (2)

XavierStuvw
XavierStuvw

Reputation: 1374

If you are using Anaconda, a solution could be

conda install -c main biopython 

following https://anaconda.org/main/biopython.

The official repository page helped me when I got your error message because numpy was not in place.

Upvotes: 0

nekomatic
nekomatic

Reputation: 6284

If you're using Anaconda, it's best to install all the packages you want from Anaconda if possible. You can check if a package is available with (e.g.):

conda search biopython

When I try that command it shows that biopython is available, so assuming you have access to the standard conda channels you should be able to get it this way.

Assuming you haven't already created a conda environment to work with, start by creating a new one with the packages you want to use:

conda create -n myenvname spyder biopython

where myenvname is the name you want to give the environment - call it whatever you like. If you want to use other packages as well, add their names to the end of this command. Then once the env is completed, activate it:

activate myenvname

or if this doesn't work, on Mac or Linux:

source activate myenvname

and start Spyder in this environment:

spyder

Each time you want to use this environment in future you will need to activate it first. You may also be able to do some of these tasks through the Anaconda Navigator or via Start menu shortcuts but the command line version will always work.

If there's a package you want that isn't available from conda but is available via pip, just use the pip command after creating and activating the environment.

Upvotes: 1

Related Questions