[SciPy-user] Matplotlib problem under Windows: %HOME% expands to %USERPROFILE%

Alan G Isaac aisaac at american.edu
Tue Aug 17 20:31:45 EDT 2004


I found a Matplotlib problem under Win 2000.

THE SYMPTOM:
Matplotlib appears to install fine under Windows 2000,
but trying to include text in a plot produces
the following error message:
Traceback (most recent call last):
  [snip]
  File "C:\programs\Python23\lib\site-packages\matplotlib\font_manager.py", line 764, in __init__
    pickle.dump(self.ttfdict, file(ttfcache, 'w'))
IOError: [Errno 2] No such file or directory: '%USERPROFILE%\\.ttffont.cache'

THE PROBLEM:
In matplotlib's font_manager.py, we find the line
        ttfpath = os.environ.get('HOME', get_data_path())
(as well as one more problematic use of HOME).
Under Windows 2000 (and other Windows?),
%HOME% expands to %USERPROFILE%,
*not* to the user's home directory.
%USERPROFILE% in turn expands to the user's home directory,
but this expansion is not done by the line above.

COMMENT:
this problem affects the installation as well:
a directory called literally '%USERPROFILE% is created!

THE HACK for Windows users with the problematic install
and behavior:
change HOME to USERPROFILE in font_manager.py.

Hopefully there is also a simple solution for Matplotlib,
but I'm just an end user so I won't propose one.

Cheers,
Alan Isaac






More information about the SciPy-User mailing list