WinXP vs. Win98

Fredrik Lundh fredrik at pythonware.com
Wed Oct 26 11:49:59 EDT 2005


sidanko at scientist.com wrote:

> I use Python 2.3.3 (Enthought edition) with wxPython and it is
> installed on both WinXP and Win98. On Win98 machine I have the
> following error:

>   File "C:\PYTHON23\lib\site-packages\freetype\font_lookup.py", line
> 24, in ?
>     font_dirs.append(os.path.join(os.environ[ 'systemroot' ],'fonts'))
>   File "C:\PYTHON23\lib\os.py", line 417, in __getitem__
>     return self.data[key.upper()]
> KeyError: 'SYSTEMROOT'
> >>>

> Hovewer running very the same script on WinXP machine I have no
> problems at all. What's wrong? Kiva package (as well as others) is
> installed properly. Where to dig?

Windows XP has SystemDrive and SystemRoot environment variables,
while Windows 98 don't seem to have them.

a quick workaround is to set the SystemRoot environment by hand (it should
point to the Windows system directory; usually c:\windows. iirc, you have to
edit AUTOEXEC.BAT or run the MSCONFIG utility to set them).

alternatively, you can add the following fix to your application code:

    import os
    os.environ["SystemRoot"] = os.environ.get("windir", "c:\\windows")

(put it *before* the wxplot import code)

a better fix is to make the freetype font_lookup code a bit more robust.

</F>






More information about the Python-list mailing list