Let's say "D:\Temp\Subfolder\mytest.exe"
is not in the PATH yet. I tried:
import os, sys, subprocess
sys.path.append("D:\Temp\Subfolder") # 1
os.environ['PATH'] += "D:\Temp\Subfolder" # 2
but in both cases, this fails:
os.system('mytest')
subprocess.Popen('mytest')
Question: how to set the PATH for the currently running process, such that os.system
and subprocess.Popen
(or those commands called by imported libraries, this is my use case) don't fail?
PS: I'm looking for a solution without having to manually edit environment variables with Windows' GUI: Control Panel > System > Advanced system settings > Environment variables > ...