Reboot to Refresh Environment Variables¶
- date:
2010-04-06 10:00
- author:
admin
- category:
python, web development
- tags:
environment variables, idle, iis, python
- slug:
reboot-to-refresh-environment-variables
- status:
published
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”)
- orphan:
Comments¶
1. Thomas Wood **
The royal mail have not relaxed their copyright over the PAF, it was the Ordnance Survey that released their copy of the postcode centroids as part of their Opendata scheme.
Reply2. geographika **
additional link.
ReplyAdd Comment