How to activate Anaconda environment

I am on Windows 8 using Anaconda 1.7.5 64bit.

I created a new Anaconda environment with

conda create -p ./test python=2.7 pip

from C:\Pr\TEMP\venv\ .

This works well (there is a folder with a new python distribution). conda tells me to dial

activate C:\PR\TEMP\venv\test

to activate the environment, however this returns:

No environment named "C:\PR\temp\venv\test" exists in C:\PR\Anaconda\envs

How to activate the environment? What am I doing wrong?

+121
python virtualenv conda anaconda
Nov 19 '13 at 20:25
source share
9 answers

If this happens, you need to set the PATH for your environment (so that it gets the correct Python from the environment and Scripts \ on Windows).

Imagine you created an environment called py33 using:

 conda create -n py33 python=3.3 anaconda 

Here the folders are created by default in Anaconda \ envs, so you need to set PATH as:

 set PATH=C:\Anaconda\envs\py33\Scripts;C:\Anaconda\envs\py33;%PATH% 

Now this should work in the command window:

 activate py33 

The line above is Windows, equivalent to the code that usually appears in manuals for Mac and Linux:

 $ source activate py33 

Additional information: https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/8T8i11gO39U.

Does anaconda create a separate PYTHONPATH variable for each new environment?

+141
Feb 11 '14 at 16:15
source share

Use cmd instead of Powershell! I spent 2 hours before I switched to CMD and then it worked

create environment:

 conda create -n your_environment_name 

see the list of conda environments:

 conda env list 

activate your environment:

 conda activate your_environment_name 

These are all people

+29
Dec 22 '18 at 12:44
source share

Note that the command to activate the environment has changed in Conda 4.4. The recommended way to activate the environment now is to conda activate myenv instead of source activate myenv . To enable the new syntax, you must modify your .bashrc . The line that is currently reading something like

 export PATH="<path_to_your_conda_install>/bin:$PATH" 

Must be changed to

 . <path_to_your_conda_install>/etc/profile.d/conda.sh 

This only adds the conda command to the path, but does not yet activate the base environment (which was previously called root ). To do this, also add another line

 conda activate base 

after the first command. See all the details in the December 2017 Anaconda blog post . (I think that this page is currently missing .../conda.shconda activate base between two lines, it says .../conda.shconda activate base ).

(This answer is valid for Linux, but may be relevant for Windows and Mac)

+8
Nov 03 '18 at 13:03
source share

As you can see from the error message, the paths you specified are incorrect. Try it like this:

 activate ..\..\temp\venv\test 

However, when I needed to install Anaconda, I downloaded it from here and installed it in the default path ( C:\Anaconda ), and then put this path in the environment variables, so now the Anacondas interpreter is used by default. For example, if you use PyCharm, you can specify the interpreter there directly.

+7
Nov 19 '13 at 20:55
source share

Below is a description of how this worked for me

  • C: \ Windows \ system32> set CONDA_ENVS_PATH = d: \ your \ location
  • C: \ Windows \ system32> cond info

Shows a new path to the environment.

  1. C: \ Windows \ system32> conda create -n YourNewEnvironment --clone = root

Cloning the default root directory environment

  1. C: \ Windows \ system32> activate YourNewEnvironment

Disabling the d: \ yourDefaultAnaconda3 environment ... Activating the d: \ your \ location \ YourNewEnvironment environment ...

  1. [YourNewEnvironment] C: \ Windows \ system32> conda info -e

Konda Wednesday: #

YourNewEnvironment
* d: \ your \ location \ YourNewEnvironment

root d: \ YourDefaultAnaconda3

+4
Feb 05 '16 at 1:18
source share

I had the same thing, the fix seems to have been made in the source.

+1
Feb 04
source share

let's say your environment is called "demo" and you are using anaconda and want to create a virtual environment:

(if you want Python3)

  conda create -n demo python=3 

(if you want Python2)

  conda create -n demo python=2 

After executing the above command, you should activate the environment using the following command:

  source activate demo 
+1
Jun 28 '19 at 13:34 on
source share

I tried to activate env from Jenkins' job (in bash) using conda activate base but it failed, so after many attempts this worked for me:

 source /opt/anaconda2/bin/activate base 
0
Jul 25 '19 at 11:53 on
source share
  1. Make sure conda is installed and in your PATH open the terminal client. Type conda -V at the command prompt on the terminal and press enter. If conda is installed, you should see something like the following.

    Konda -V

conda 3.7.0 2. Check the relevance of conda In the terminal client, enter

 conda update conda 

Update all packages, if necessary, by typing y to continue. 3. Create a virtual environment for your project. In the terminal client, enter the following, where yourenvname is the name you want to call your environment, and replace the xx version of Python that you want to use. (To first see a list of available versions of Python, enter

 conda search "^python$" and press enter.) conda create -n yourenvname python=xx anaconda 

Press y to continue. This will install the Python version and all associated anaconda packaged libraries at path_to_your_anaconda_location / anaconda / envs / yourenvname. 4. Activate the virtual environment. To activate or switch to your virtual environment, simply enter the following, where yourenvname is the name you gave your environment when you created it.

 source activate yourenvname 

Enabling conda changes the PATH and shell variables, pointing to the particular Python isolated sandbox you created. The command line will change to indicate which environment you are in by adding (yourenvname). To see a list of all your environments, use the conda info -e command. 5. Install additional Python packages in a virtual environment. To install additional packages only in your virtual environment, enter the following command, where yourenvname is the name of your environemnt and [package] is the name of the package you want to install. Failure to specify "-n yourenvname" will install the package in the Python root installation.

 conda install -n yourenvname [package] 
  1. Deactivate your virtual environment. To end a session in the current environment, enter the following: There is no need to specify the name envname, which is ever active at the moment, will be deactivated, and the PATH and shell variables will be returned to normal.

    deactivate source

  2. Remove the unnecessary virtual environment. To remove the conda environment, enter the following, where yourenvname is the name of the environment you want to delete.

    Konda remove -n yourenvname --all

-3
Mar 19 '18 at 3:51
source share



All Articles