I have been stuck on this problem for a while now and I have tried different solutions online but still cannot get it resolved. I already tried these out:
How to run a python script with its environment from another script with another environment?
How to use path of current conda environment's python as shebang for a script?
How do I activate a conda env in a subshell?
I have a script1.py
which uses conda environment my_env1
and calls with CLI to another script script2.py
that requires my_env2
(also conda environment). script2.py
is called from script1.py
which is activated with my_env1
. script1.py
works fine when I activate my_env2
, but does not work when I run it with my_env1
.
In my script2.py
, I have used following 2 Shebangs separately (but none of them seem to work):
#!C:/Users/<user_name>/.conda/envs conda run -n my_env2 python
#!C:/Users/<user_name>/.conda/envs/my_env2 python
In conda environments, my_env2
and my_env1
, there is no bin
folder, so I tried using conda install --name <env_name> python
; still doesn't solve it. Any help on this would be much appreciated. Thanks.