Question: Biopython installation/set path fails in conda env
gravatar for salamandra
27 days ago by
salamandra230 wrote:

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


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: but it still doesn't work.

biopython • 148 views
ADD COMMENTlink modified 26 days ago • written 27 days ago by salamandra230
gravatar for RamRS
27 days ago by
Houston, TX
RamRS24k wrote:

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

ADD COMMENTlink written 27 days ago by RamRS24k

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 REPLYlink written 27 days ago by salamandra230

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 REPLYlink modified 27 days ago • written 27 days ago by RamRS24k

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\\', '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 REPLYlink written 26 days ago by salamandra230

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 REPLYlink modified 26 days ago • written 26 days ago by jflopezfernandez30
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 755 users visited in the last hour