python crashes when plot saved as png

I followed the link in the matplotlib site and installed gtk

    > 2.2.4.1 from the sf site and the problem goes away. This
    > version has all the images libraries with them. I must
    > bookmark it!

Good news ...

    > Another question: I've set the environmental variable AFMPATH
    > in the registry via the control panel but matplotlib
    > complains that the .afm files are not there.

I cannot replicate this problem on my system. Are the *.afm files in
E:\Py23e\share\matplotlib? Are you sure you are running the right
version of python, ie, do you still get the error with

  > E:\Py23e\python simple_plot.ps -dPS

You might want to add a diagnostic debug line to
backends/backend_ps.py to print the paths that it is searching. After
line 422 in that file, insert a new line that prints the paths, eg,

    def _get_afm_filenames(self):
        paths = [os.path.join(distutils.sysconfig.PREFIX, 'share', 'matplotlib')]
        if os.environ.has_key('AFMPATH'):
            afmpath = os.environ['AFMPATH']
            if afmpath.find(';')>0: #win32 style
                paths.extend(afmpath.split(';'))
            elif afmpath.find(':')>0: # unix style
                paths.extend(afmpath.split(':'))
            else:
                paths.append(afmpath)
*** print paths
        fnames =

And let me know what it reports. If you are using the fonts that ship
with matplotlib, you shouldn't even need to set the AFMPATH because it
automatically looks in the share/matplotlib subdir of your python
install dir.

You may also want to verify that matplotlib is finding your
environment variable by doing

python

import os
print os.environ.has_key('AFMPATH')

If the *.afm fonts are in the share/matplotlib dir, and you are using
the right python, and the paths look correct from the diagnostic
information above, the only thing I can think of is that these files
are not readable by you (admin versus user thing?). To test this try

python

fh = file('E:\Py23e\\share\\matplotlib\\phvl8a.afm', 'r')
s = fh.read()
len(s)

Let me know....
JDH

John Hunter wrote:
>

    > Another question: I've set the environmental variable AFMPATH
    > in the registry via the control panel but matplotlib
    > complains that the .afm files are not there.

I cannot replicate this problem on my system. Are the *.afm files in
E:\Py23e\share\matplotlib? Are you sure you are running the right
version of python, ie, do you still get the error with

  > E:\Py23e\python simple_plot.ps -dPS

[snipped]

And let me know what it reports. If you are using the fonts that ship
with matplotlib, you shouldn't even need to set the AFMPATH because it
automatically looks in the share/matplotlib subdir of your python
install dir.

I can confirm that if the font files are installed in the default location under the system python tree, it works. Setting AFMPATH also works in linux.

You may also want to verify that matplotlib is finding your
environment variable by doing

python

import os
print os.environ.has_key('AFMPATH')

>>> import os
>>> os.environ["AFMPATH"]
'E:\\Py23e\\share\\matplotlib'

If the *.afm fonts are in the share/matplotlib dir, and you are using
the right python, and the paths look correct from the diagnostic
information above, the only thing I can think of is that these files
are not readable by you (admin versus user thing?). To test this try

python

fh = file('E:\Py23e\\share\\matplotlib\\phvl8a.afm', 'r')
s = fh.read()
len(s)

>>> fh = file('E:\Py23e\\share\\matplotlib\\afm\\phvl8a.afm', 'r')
>>> len(fh.read())
15627

Let me know....
JDH

Regards,
ST

···

--