Conda environments and .BAT files

Hans picture Hans · Jul 10, 2014 · Viewed 34.5k times · Source

I am setting up calls to python (Anaconda distribution) via BAT files and the windows task scheduler.

I've now used environments for the first time and was trying to set a .bat file up as below:

activate [my_env]
python my_script.py
deactivate

Unfortunately it appears that the second command does not get executed.

Answer

Chris Burgoyne picture Chris Burgoyne · Aug 1, 2016

Use the 'call' command when activating/deactivating the environment.

call activate [my_env]
python my_script.py
call conda deactivate

See https://github.com/conda/conda/issues/794