How to activate an Anaconda environment from the command line?
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.
Related videos on Youtube
Comments
-
Seppukki almost 2 years
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.
-
cvanelteren over 5 yearssource activate [env] or conda activate [env] edit: make sure conda is in your windows path.
-
Seppukki over 5 yearsIt isn't in my path, how to add it?
-
cvanelteren over 5 yearsDid you read the install instructions. Edit additionally IIRC during installation on windows there is a box you should tick to add it to path.
-
Seppukki over 5 yearsNo I didn't, but it's already installed. How can I add it to my pat?
-
cvanelteren over 5 yearsYou can add it to path by going to Edit environment variables and then adding conda ex to path. First you should locate where you installed conda executable.
-
cvanelteren over 5 yearsHowever redoing the installation with the box ticked will be easier.
-
double-beep over 5 yearsSo, what does
where /r "C:\" conda.exe
says in cmd? -
Seppukki over 5 yearsI get a lot of lines output, but I think I need this one:
C:\Users\user\Anaconda3\Scripts\conda.exe
-
double-beep over 5 yearsWhere is
conda
installed? -
darthbith over 5 yearsDon't put Anaconda on your
PATH
(it is not recommended by Anaconda). Instead, use the Anaconda Prompt. -
Seppukki over 5 yearsBut can I open the Anaconda prompt with python and execute commands in it?
-
darthbith over 5 yearsNo, you run Python from within the Anaconda Prompt. The Anaconda Prompt is opened from, e.g., the Start Menu.
-
Seppukki over 5 yearsI think you don't get it... I want to write a script which accesses the command line (CMD or anaconda)
-
jww over 5 yearsStack Overflow is a site for programming and development questions. You should use another site on the Stack Exchange network for this question.
-
Seppukki over 5 yearsCan you suggest a site?
-
Soren about 5 yearsThis question is very specific and should be re-opened.
-
-
Seppukki over 5 yearsconda isn't in my path and
where conda
doesn't return anything usefull, how can I add conda to my path? -
Seppukki over 5 yearsI already have an environment.
-
Seppukki over 5 yearsThat's not what i want, I want to open my environment using the command line.
-
hash_ir over 5 yearsBy environment do you mean your virtual env or the deafult conda env?
-
hash_ir over 5 yearsFor either of the case, add conda to your environment variable (user variable). It generally is C:\ProgramData\Anaconda3 but check for yours. And ProgramData is a hidden folder.
-
Seppukki over 5 yearshow should I name the environment variable
-
Seppukki over 5 yearsand do i need to use the path to the \Anacond folder or to the conda.exe file?
-
Seppukki over 5 yearsWhen I run the 'path' command, I can use the
conda
command but i get an error when i runconda activate
, it's to big to post here but i says that my shell has not properly been configured for conda activate. the solutions provided in the error are for linux... what now? -
hash_ir over 5 yearsYou don't have to name it. In the user variable "path", just add an entry for the Anaconda folder. That will do it!!
-
Seppukki over 5 yearsThx for the support!
-
Soren about 5 yearsYou are answering a different question. The question is about starting a conda environment from cmd.exe and specifically not the anaconda prompt.
-
wjakobw almost 5 yearsSince this came up when I websearched the issue, a note for posterity: After adding "my_install_location/Anaconda3/condabin" to the PATH environment variable, I can use conda commands in cmd.exe, without the Anaconda Prompt. (This works through the .bat-files "conda.bat" and "activate.bat" that are in condabin.)
-
mr3 over 4 yearsthis worked for me in a .cmd:
set PATH=
_<conda base install folder>_\Scripts;
_<conda base install folder>_;%PATH%
call conda.bat init cmd.exe
call conda.bat activate
_<desired environment name>_ <do stuff in the env> -
Lucas925 over 3 yearsDoes not answer the question that was asked