How to make batch files run in anaconda prompt

After installing anaconda3 on windows, I can run python commands from the anaconda prompt, but not from the windows command prompt. I would like to make a desktop shortcut to activate my environment and run spyder from it. I used to do this with a .bat file, but now that I cannot run the python commands from cmd.exe , this does not work.

Is there an alternative way to run batch files for anaconda request? I know that I could just change my PATH to get cmd.exe to run python commands, but I would like to avoid this if possible.

+27
source share
4 answers

I believe all that Anaconda offers is to open CMD and run the batch file. Make the first command of your script:

 call <anaconda_dir>/Scripts/activate.bat <anaconda_dir> 
+26
source

Extending Jeremy's answer:

You need to use call for the "activ.bat" script, as well as for any subsequent commands related to Anaconda / Python. Otherwise, the prompt will end immediately after running the commands, even if you use the pause statement. Please see below for an example:

 set root=C:\Users\john.doe\AppData\Local\Continuum\anaconda3 call %root%\Scripts\activate.bat %root% call conda list pandas pause 
+15
source

add

 call "<anaconda_dir>\Scripts\activate.bat" 

to the beginning of your script (in fact, it does not require an argument and activates the base environment by default).

Please note that after this line you can use CONDA_ CONDA_!

+8
source

Powershell Version:

 $qtconsole="C:\Users\<YourUserName>\.anaconda\navigator\scripts\qtconsole.bat" start-process $qtconsole -WindowStyle Hidden 

Note: this script will run only one qtconsole instance at a time due to the limitations of the Linux QT GUI Linux DLL, which only supports one instance of the same exe file that is running at a time. This is probably why they use "Anaconda Navigator" to run QtConsole programs to get around this limitation.

0
source

Source: https://habr.com/ru/post/1271948/


All Articles