5👍
✅
It will only be in sys.path
for the current Python instance. To get it for another, use the env
argument to Popen
with os.pathsep
:
import subprocess
import os
import sys
subprocess.Popen(["python",path], env = {'PYTHONPATH': os.pathsep.join(sys.path)})
You should really look into the multiprocessing
module for running multiple instances of Python.
Edit: @Graham pointed out in a comment that you might want to run this external script with a different version of Python than the one you’re calling it from. That sounds unlikely to me, but if so, you’d need most of PYTHONPATH
to be different for it to work, so you’d need to just add /home/socialsense/ss/src
.
👤agf
Source:stackexchange.com