I am attempting to execute a function within a Python script as a subprocess using its own interpreter, specified in the subprocess.run() call. This interpreter may include packages not present in my local Python environment. When I debug the file, errors occur due to these missing libraries in my local python instead of the one linked in the command. Am I misunderstanding something?
try:
proc = subprocess.run(
[
r'C:\Users\user\AppData\Local\Programs\Python\Python311\python.exe',
r'C:\subprocess_python\my_file_subprocess.py',
str(self.x), str(self.y), str(self.z)
],
capture_output=True,
check=True
)
except subprocess.CalledProcessError as proc_err:
print("An exception occurred in the subprocess: \n ", proc_err)
print("stdout : \n", proc_err.stdout.decode())
print("stderr : \n", proc_err.stderr.decode())
exit(1)
my_file_subprocess.pyrequires.PYTHONPATHenvironment variable (which is used by all Python's that launch) rather than installing things properly per-interpreter.