I apologize if what I'm trying to achieve is not Pythonic - I recently moved to the language.
I have a project directory structured like so:
root
--proj1
----venv
----main.py
--proj2
----venv
----main.py
Both proj1 and proj2 run under their own virtual environments. I am trying to call proj2/main.py from proj1/main.py, whilst executing proj2/main.py under its own venv. I have tried:
import subprocess
s2_out = subprocess.check_output([sys.executable, r"..\proj2\__main__.py", "arg"])
This invokes successfully, but I am getting all manner of not found exceptions, etc. I am guessing this is the reason why.
Please let me know if there is a better approach!
pyenv
by any chance? I know how to do this if you usepyenv
. – Hath