[triangle-zpug] can't find font problem

Joseph Mack NA3T jmack at wm7d.net
Sun Mar 30 15:21:35 CEST 2008

On Sat, 29 Mar 2008, David Handy wrote:

> The Python path is only used for finding Python modules and packages, and
> then only by the "import" statement. For opening regular files, you have to
> specify a full pathname or a path relative to the current directory.

OK. Thanks

> In this case, it looks you are trying to load the font file out of the PIL
> package directory. You can find the directory of a Python package like this:
>>>> import PIL
>>>> PIL.__file__
> '/usr/lib/python2.4/site-packages/PIL/__init__.pyc'
>>>> import os
>>>> os.path.dirname(PIL.__file__)
> '/usr/lib/python2.4/site-packages/PIL'
> So I suppose you could do something like this in your code:
> label_font=ImageFont.load(os.path.dirname(PIL.__file__) + "/courR18.pil")


There's demo code out there eg



(look for "arial.pil")

that finds the font without doing anything special. I 
thought that maybe there was some font path or python path 
that allowed python to find the file without me having to do 

> By the way, I just now looked in the PIL directory on my 
> computer and didn't see any .pil files there; I assume you 
> put courR18.pil in that directory yourself?

I moved the files from directory to directory, hoping they'd 
be picked up by the load command. Their current location is 
just where they are now. If there's a canonical location, 
I'd be happy to move them there.


Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!

More information about the TriZPUG mailing list