I'am trying to start an exe file (the exe file is the output of c++ project compiled with visual studio) from a python program. In the properties of this c++ project (configuration ->properties-> debugging-> environment) the following setting in the
(PATH = %PATH%;lib\testfolder1;lib\testfolder2)
is given.
is there any way to set path environment variable to
in a python program?
Thanks in advance for your replay
You can update PATH using several methods:
import sys
sys.path += ["c:\\new\\path"]
print sys.path
or
import os
os.environ["PATH"] += os.pathsep + os.pathsep.join(["c:\\new\\path"])
print os.environ["PATH"]
Repost Yaron's answer but dropped the sys.path. As in his post's comment, sys.path is for module search, not command search. PATH is for command search.
import os
os.environ["PATH"] += os.pathsep + os.pathsep.join(["c:\\new\\path"])
print os.environ["PATH"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With