Reboot to Refresh Environment Variables

I wasn’t aware that if you change Windows environment variables that are used by IIS then you need to reboot the machine for the changes to take effect. As described by David Wong

This is because NT services like IIS inherit their environment from services.exe, which does not get updated when you change system environment until you reboot.

This knowledge may save a couple of hours of frustration if you are running Python scripts on IIS through PyISAPIe.


If you add paths to your PYTHONPATH or PATH system variables to use a Python package (such as MapScript or GDAL), then the same script may run without problems in IDLE, but continue to produce errors when run through the web server.

If you are running a script in IDLE then you need to restart IDLE itself to refresh the environment variables.

Other Options

I’ve not tried this method myself but R. Teachout suggests a registry hack that allows you to override the Windows environment variables in IIS 6.

You can also override the environment variables in the Python scripts themselves. For example to change the GDAL_DRIVER_PATH variable use:

os.environ[“GDAL_DRIVER_PATH”] = “C:\ms4w\gdalplugins”

To print out current environment variables (assuming you are testing in IDLE):

print os.getenv(“GDAL_DRIVER_PATH”)

3 views shared on this article. Join in...

Pings to this post

  1. […] Where WorkingCopyPath is the path to the working copy being checked. If you aren’t using a copy of the sourcecode from SVN then you will receive errors such as “SubWCRev : ‘D:PyISAPie’ is not a working copy.” If you have only just installed TortoiseSVN then make sure you log off or restart Windows so that your environment variables are updated. […]

  2. […] you have only installed Python during your log in session then reboot to refresh your environment variables. This should allow you to use the easy_install program directly from the Windows Command Prompt (by […]

  3. Amit Agarwal says:

    Verify all the paths in the PATH directory…

    I found your entry interesting thus I’ve added a Trackback to it on my weblog :)…

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>