[Pythonmac-SIG] PIL and py2app on Leopard

Martin Dunschen zabaione at uk2.net
Wed Apr 9 13:20:56 CEST 2008


The recommendation is to import like this:

import Image
...

not
from PIL import Image
...

This reqires that PYTHONPATH is set up to find the module.


PIL should be in your PYTHONPATH environment variable. Test this:

import sys
print sys.path

and see if PIL is somewhere in there.

When you run setup.py, does it find the module Image? Check the output.
Put some debug code into the script: print the path for example from 
your application.

I take it that if you run your python without wrapping it into an 
application everything works as expected?

Martin


> 
> Subject:
> Re: [Pythonmac-SIG] PIL and py2app on Leopard
> From:
> Martin Dunschen <zabaione at uk2.net>
> Date:
> Tue, 08 Apr 2008 15:26:22 +0100
> To:
> pythonmac-sig at python.org
> 
> To:
> pythonmac-sig at python.org
> 
> 
> PIL stands for "Python Imaging Library". "Image" is the module you 
> import to use this library.
> 
> In your setup.py you need to make sure that the "Image" module is 
> included in building the app. Read the documentation to py2app (or 
> py2exe) to find how you can ensure that this module will be included in 
> the modules your application depends on: I think you've got to use 
> something like this:
> 
> setup(
>     options=dict(
>         py2app=dict(
> ...
>             packages='wx, PIL',
> ...
> 
> 
> in your setup.py file. This says that you want the packages wx and PIL 
> (Image module) included in your distribution (the application).
> 
> Hope this helps,
> 
> Martin
> 
> 
> ------------------------------------------------------------------------
> 
> Subject:
> Re: [Pythonmac-SIG] Double-clickable wxpython application?
> From:
> Henning Hraban Ramm <hraban at fiee.net>
> Date:
> Tue, 8 Apr 2008 21:38:22 +0200
> To:
> pythonmac-sig at python.org
> 
> To:
> pythonmac-sig at python.org
> 
> 
> Am 2008-04-08 um 02:40 schrieb Kevin Horton:
>>>
>>> Just put an alias to your python file on the Desktop.
>>> On doubleclick it starts Terminal, but it works.
>> I don't know why, but this does not work for me.  In my account
>> nothing happens, and no messages in Console.app giving a clue why.  I
>> restarted the computer, and created a brand new user account, with
>> admin priviledges.  In that account, if I double the script file, or
>> an alias, Terminal starts, I see that it runs "/path/to/my script ;
>> exit;".  The wxpython application does not start.  It does run
>> normally if I start it manually from the command line in Terminal.
>>
>> I tried doubleclicking the script file on another Mac, and I get the
>> identical result as I did on the fresh user account on the first Mac
>> - i.e. the script is called, but immediately exits, and the
>> application does not start.
>>
>> It is quite possible that I have done something non-standard in my
>> script that is at fault here, but I have no clue on what to look for.
> 
> Try to map *.py on Python Launcher.
> And I guess it helps if you make your script executable (chmod a+x) and 
> have a working shebang line like this:
> 
> #!/usr/bin/env python
> 
>>> There's also Platypus to wrap any script, see http://
>>> www.sveinbjorn.org/platypus
>> I tried that on both Macs - the Platypus wrapper application starts,
>> but the wxpython application does not start.
> 
> I never tried Platypus with wxPython, sorry.
> 
> Greetlings from Lake Constance!
> Hraban
> ---
> http://www.fiee.net
> https://www.cacert.org (I'm an assurer)
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Subject:
> Re: [Pythonmac-SIG] Double-clickable wxpython application?
> From:
> Kevin Horton <khorton01 at rogers.com>
> Date:
> Tue, 8 Apr 2008 20:54:49 -0400
> To:
> pythonmac-sig at python.org
> 
> To:
> pythonmac-sig at python.org
> 
> 
> On 8 Apr 2008, at 15:38, Henning Hraban Ramm wrote:
> 
>> Try to map *.py on Python Launcher.
> 
> I didn't even know PythonLauncher.app existed, but SpotLight found it, 
> and I did the mapping.  PythonLauncher from Apple's python 2.3 on OS 
> 10.4 didn't work, but the one from MacPython 2.5 did work.  At least 
> this worked on my machine, running 10.4.  But, on my wife's machine, 
> running 10.5, where this script will live once it is polished up, 
> PythonLauncher will not do the job.  It starts, then a Terminal window 
> opens, then PythonLauncher quits.  I tried with both the system python, 
> and with MacPython.  I tried logging out, and back in, but that did not 
> help.  I'll play with this some more tomorrow evening.
> 
>> And I guess it helps if you make your script executable (chmod a+x)
>> and have a working shebang line like this:
>>
> Subject:
> Re: [Pythonmac-SIG] PIL and py2app on Leopard
> From:
> Jörg Birkhold <joerg.birkhold at gmail.com>
> Date:
> Wed, 9 Apr 2008 10:51:30 +0200
> To:
> pythonmac-sig at python.org
> 
> To:
> pythonmac-sig at python.org
> 
> 
> hello,
> 
> i tried this but still got the same error.
> in my code i use:
> 
> from PIL import Image
> 
> my setup.py:
> 
> from setuptools import setup
> 
> setup(
>     app=["converter.py"],
>     setup_requires=["py2app"],
>     options=dict(py2app=dict(packages='PIL',)),
> )
> 
> in the terminal i get:
> *** using recipe: PIL ***
> 
> that looks ok but still that line throws an error:
> from PIL import Image
> 
> any ideas?
> 
> thanks a lot
> 
> joerg
> 
> Am 08.04.2008 um 16:26 schrieb Martin Dunschen:
> 
>> PIL stands for "Python Imaging Library". "Image" is the module you
>> import to use this library.
>>
>> In your setup.py you need to make sure that the "Image" module is
>> included in building the app. Read the documentation to py2app (or
>> py2exe) to find how you can ensure that this module will be included in
>> the modules your application depends on: I think you've got to use
>> something like this:
>>
>> setup(
>>     options=dict(
>>         py2app=dict(
>> ...
>>             packages='wx, PIL',
>> ...
>>
>>
>> in your setup.py file. This says that you want the packages wx and PIL
>> (Image module) included in your distribution (the application).
>>
>> Hope this helps,
>>
>> Martin
>> _______________________________________________
>> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
>> http://mail.python.org/mailman/listinfo/pythonmac-sig
> 
> 



More information about the Pythonmac-SIG mailing list