How to activate an Anaconda environment from the command line?

Viewed 32174

I'm trying to access a module which is installed in a virtual environment, but the problem I've run into is that I can't activate my environment from the command line (Windows cmd).

Is there a command to activate an environment from the command line?

It is for a Python project. So if you can find a solution to open the Anaconda command line and execute commands there, it would be also great.

3 Answers

To create an environment: conda create --name myenv

NOTE: Replace myenv with the environment name.

When conda asks you to proceed, type y:

proceed ([y]/n)?for more detail click this

about activate this may help

to add anaconda to path

In Windows, you will have to set the path to the location where you installed Anaconda3 to.

For me, I installed anaconda3 into C:\Anaconda3. Therefore you need to add C:\Anaconda3 as well as C:\Anaconda3\Scripts\ to your path variable, e.g. set PATH=%PATH%;C:\Anaconda3;C:\Anaconda3\Scripts.

type conda in cmd
You should be in the conda environment.

If it isn't, you have to add Anaconda to your environment path. You can try where conda to see where your installation is at.

If windows cmd doesn't recognise conda, open Anaconda prompt and write the following command:

activate <env_name>

Then, you will be seeing your prompt with your current environment in parentheses like this:

(env_name) $

For detailed info, click here

Related