kiryha Posted November 28, 2018 Share Posted November 28, 2018 How to add a new path to environment variable? For example, trying to add a new path to the "PATH" (i need HOUDINI_PATH indeed): import os print os.environ['PATH'] os.environ['PATH'] = 'C:/TEMP;&' print os.environ['PATH'] >> C:\Program Files\Microsoft MPI\Bin\;C:\Program Files\Java\jdk-10.0.1\bin; ... >> C:/TEMP;& So, os.environ['PATH'] = 'C:/TEMP;&' overwrites existing "PATH" variable. This way os.environ['PATH'] += os.pathsep + 'C:/TEMP;' is working. I was thinking "&" should do the trick (append a string to the variable instead of replacing it), but it does not work. So I wonder if I misunderstood something with "&" and "+=" is the only solution. Quote Link to comment Share on other sites More sharing options...
hall Posted December 13, 2018 Share Posted December 13, 2018 os.environ["PATH"] += os.pathsep + os.path.join(path) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.