8

I want to install python packages after virtualenv is created by conda. But I got the following error, does anyone know how to install packages into virtualenv created by conda ?

/Users/jzhang/anaconda/lib/python3.5/site-packages
(env_2) jzhangMBPr:env_2 jzhang$ conda install numpy
Fetching package metadata .........


CondaEnvironmentNotFoundError: Could not find environment: /Users/jzhang/anaconda/envs/env_2 .
You can list all discoverable environments with `conda info --envs`.
zjffdu
  • 25,496
  • 45
  • 109
  • 159
  • You used venc or ```conda create``` to build this env? What is the output of the recommended command-line? – sascha Jan 23 '17 at 08:30

3 Answers3

7

First, enter into an environment that you have created by the following command:

activate your_environment_name

Then, you will be in particular in your environment. Now, you can install numpy using this command:

conda install -c anaconda numpy
5

From the help:

Target Environment Specification: -n ENVIRONMENT, --name ENVIRONMENT Name of environment.

So all you need is to do: conda install -n YOUR_ENVIRONMENT_NAME PACKAGE

Amir
  • 1,871
  • 1
  • 12
  • 10
2

I didn't use conda but as far as I understand from the docs, it should work like this:

  1. Create your env conda create --name snowflakes biopython
  2. Activate your env source activate snowflakes
  3. Install what you need conda install what-you-want or pip install what-you-want
Vitalie Maldur
  • 553
  • 3
  • 19
  • 3
    Don't use ```pip install X```, use ```conda install X```. The latter will install the given binaries while pip will do the usual stuff, most of the times compiling from the sources (which defeats somehow the purpose of conda). Only use this, if there is no conda-package. – sascha Jan 23 '17 at 09:10
  • 1
    @sascha conda install doesn't always cover pip install. For instance, `conda install graphviz` installs the graphviz binaries, but not the graphviz Python package. So if you need the Python package you need to run `conda install graphviz && pip install graphviz`. – Guy Rapaport Aug 10 '17 at 08:22