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.
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):