1

I have a setup script (not mine) which reads a certain system variable. I tried setting this in two ways:

  • Going to control panel > User Accounts > Change my environment variables
  • In command line: setx myvar myvalue

I set it as user variables, since i don't have the rights to set system variables. If i open a new command line window and type set, my variable shows there correctly.

However, if i start python and run the following script, i don't see my variable:

import os
print os.environ

I am using windows 10 and python 2.7. Modifying the code to get the variable is not possible since it is code from an external library.

user3053216
  • 777
  • 1
  • 9
  • 24
  • 1
    have you tried to start python in the command where it shows with `SET` ? because it should (and it does) be activated, what you're doing is OK. Worst case: logoff & logon to be sure all env. variables are propagated to all processes (but it's not necessary with `SETX`) – Jean-François Fabre Jul 26 '17 at 14:23
  • Logoff and Logon did the trick. Thank you – user3053216 Jul 27 '17 at 07:52

0 Answers0