Hans Hans - 1 year ago 77
Python Question

Conda environments and .BAT files

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

file up as below:

activate [my_env]
python my_script.py

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

Answer Source

Are you sure you need a batch file? I think this should work.

cmd "/c activate [my_env] && python my_script.py && deactivate"

When I made a simple file containing


Which I called myprint.py and ran

cmd "/c activate anaconda33 && python myprint.py && deactivate"

This worked for me. You could also put this in a one line batch file.