How to make batch files run in anaconda prompt How to make batch files run in anaconda prompt windows windows

How to make batch files run in anaconda prompt


I believe all the Anaconda prompt does is open CMD and run a batch file. Make the first command of your script:

call <anaconda_dir>/Scripts/activate.bat <anaconda_dir>


Extending Jeremy's answer:

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

set root=C:\Users\john.doe\AppData\Local\Continuum\anaconda3call %root%\Scripts\activate.bat %root%call conda list pandaspause


Thanks to this thread I solved my challenge to get a windows batch file to open the Ananconda Prompt and then run some python code.

Here is the batch file:

@echo oncall C:\ProgramData\Anaconda3\Scripts\activate.batC:\ProgramData\Anaconda3\python.exe "D:\Documents\PythonCode\TFLAPI\V1.py"