I want to execute a python script executed.py
from another python script trigger.py
using the subprocess package. The executed.py
must be ran in a different conda environment than trigger.py
(let say executed_env
and trigger_env
). What is the best way to do that ? My current code of trigger.py
is:
command = "python executed.py --option1 -dir /path/to/dir"
args = shlex.split(command)
my_subprocess = subprocess.Popen(args)
It returns an error since executed.py
is ran in the trigger_env
environment.