Biopython installation/set path fails in conda env
1
0
Entering edit mode
5.2 years ago
salamandra ▴ 550

I'm working on windows. I think I installed biopython with pip in a specific conda environment. Cause with:

conda activate models
pip install biopython

says:

Requirement already satisfied: biopython in c:\users\tania\.conda\envs\models\lib\site-packages (1.74)
Requirement already satisfied: numpy in c:\users\tania\appdata\roaming\python\python35\site-packages (from biopython) (1.16.3)

However when running in pycharm:

import biopython

Gives the error:

ImportError: No module named 'biopython'

I'm sure it's installed in correct env cause I've installed other python modules there and they worked. Tried to add variable to user path as explained here: https://www.opentechguides.com/how-to/article/windows-10/113/windows-10-set-path.html but it still doesn't work.

Biopython • 3.6k views
ADD COMMENT
0
Entering edit mode
5.2 years ago
Ram 44k

I don't think it's import biopython, it's import Bio.

ADD COMMENT
0
Entering edit mode

doesn't work with Bio either. Even after adding to path of system variables: C:\Users\Tania\.conda\envs\models\Lib\site-packages Is something missing?

ADD REPLY
0
Entering edit mode

Can you do the following experiments and see where things break:

  1. Open python within the models conda env, then run import Bio to see if that works
  2. If 1 works, try running python outside the conda env, and then import Bio.
  3. If 2 works, then try import Bio from within PyCharm.

The above steps will tell you if it's python that's unable to see the module location or if PyCharm's the one acting funny. Step-1 confirms that you do have a working installation of biopython. Also, from each, print sys.path to see if the directory you added shows up in the PATH variable.

ADD REPLY
0
Entering edit mode

Fails at step 1:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'Bio'
>>> print(sys.path)
['', 'C:\\Users\\Tania\\.conda\\envs\\models\\python35.zip', 'C:\\Users\\Tania\\.conda\\envs\\models\\DLLs', 'C:\\Users\\Tania\\.conda\\envs\\models\\lib', 'C:\\Users\\Tania\\.conda\\envs\\models', 'C:\\Users\\Tania\\AppData\\Roaming\\Python\\Python35\\site-packages', 'C:\\Users\\Tania\\.conda\\envs\\models\\lib\\site-packages']
ADD REPLY
1
Entering edit mode

Is biopython listen as one of the installed packages when you run conda list -n models (before activating the environment)?

python and conda use virtual environments so you can make and throw away changes easily, but this flexibility comes at the cost of simplicity. Simply checking the PATH variable is not enough; if you know you installed it and the path is what it is, then it must not have been installed to the right virtual environment.

ADD REPLY

Login before adding your answer.

Traffic: 1797 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