[Pythonmac-SIG] py2app and PIL question

Chris Jerdonek jerdonek at gmail.com
Wed Nov 16 22:24:27 CET 2005


On Nov 16, 2005, at 12:18 PM, Bob Ippolito wrote:

> Code helps...
>
> -bob

Not sure which code is most important.  I'll go through the Traceback  
and intersperse the code.  I also inserted line numbers in parentheses:

Traceback (most recent call last):
   File  
"/Users/chris/Desktop/ER/StoveTop/Old/dist/stovetop.app/Contents/ 
Resources/Python/stovetop.py", line 205, in Click
     item.Activate(frame, event)
   File "reports.pyc", line 333, in GenerateReport

(333)  text += '<div style="float: left;"><p><strong>The number of #1  
choices received by each slate:</strong></p>' + makePie(pielist,  
"SlateRepresentation") + '</div>'


   File "reports.pyc", line 158, in makePie

(157)  import graph
(158)  mygraph = graph.PieChart(points, colors=mycolors, size=(600,  
600), title=' ')

   File "graph.pyc", line 201, in __init__

(198)   self._checkPoints(points)
         self.image=PIL.Image.new("RGB", self.size, bgColor)
         self.draw=PIL.ImageDraw.Draw(self.image)
(201)   self.font = PIL.ImageFont.truetype(font,48)

   File "PIL/ImageFont.pyc", line 202, in truetype

[Part of the PIL code.  First line is line 199.]

def truetype(filename, size, index=0, encoding=""):
     "Load a truetype font file."
     try:
(202)   return FreeTypeFont(filename, size, index, encoding)
     except IOError:
         if sys.platform == "win32":
             # check the windows font repository
             # NOTE: must use uppercase WINDIR, to work around bugs in
             # 1.5.2's os.environ.get()
             windir = os.environ.get("WINDIR")
             if windir:
                 filename = os.path.join(windir, "fonts", filename)
                 return FreeTypeFont(filename, size, index, encoding)
         raise

   File "PIL/ImageFont.pyc", line 121, in __init__
IOError: cannot open resource

# Wrapper for FreeType fonts.  Application code should use the
# <b>truetype</b> factory function to create font objects.

class FreeTypeFont:
     "FreeType font wrapper (requires _imagingft service)"

     def __init__(self, file, size, index=0, encoding=""):
         # FIXME: use service provider instead
         import _imagingft
(121)   self.font = _imagingft.getfont(file, size, index, encoding)



On Nov 16, 2005, at 12:18 PM, Bob Ippolito wrote:

>
> On Nov 16, 2005, at 11:24 AM, Chris Jerdonek wrote:
>
>> I have a python program that uses some commands from the PIL module
>> (and also wxPython).
>>
>> I have PIL installed on my Mac, and the python program works fine when
>> I run the program from the command line.  The application I get from
>> py2app also works fine -- until I get to a point in the program that
>> requires PIL.
>>
>> Does anyone have any idea why I'm getting this error message?
>>
>> I can see the ImageFont.pyc in a subdirectory of the build directory
>> that py2app created.
>
> Code helps...
>
> -bob
>



More information about the Pythonmac-SIG mailing list