zjffdu
zjffdu

Reputation: 28744

conda install doesn't work in virtualenv created in conda

I create a virtualenv using conda, and install new python packages under this env as following.

conda create --name env_2
source activate env_2
conda install biopython

ls ~/anaconda/envs/env_2/lib/python3.6/site-packages/Bio/  # biopython is installed correctly

But I still can not use Bio. Do I miss anything ?

>>> import Bio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'Bio'
>>>

Upvotes: 2

Views: 2217

Answers (1)

Roman Zhuzha
Roman Zhuzha

Reputation: 664

By default, conda create --name env_2 will install only activate, deactivate and conda packages in environment, there will be no interpreter installed:

$ ls miniconda3/envs/env_2/bin/
activate   conda      deactivate

If you want python interpreter be installed you have 3 options:

  1. Provide python as a package to install in environment:

    $ conda create --name env_2 python
    
  2. Install python as package after creating an env:

    $ source activate env_2
    (env_2)$ conda install python
    
  3. Add python to the list of default packages (documentation):

    $ cat ~/.condarc
    create_default_packages:
      - python
    

Edit 1:

Added information from comments.

Upvotes: 3

Related Questions