[Pythonmac-SIG] py2app and PyQt4

Christopher Barker Chris.Barker at noaa.gov
Mon Mar 8 20:14:30 CET 2010


Emmanuel Blot wrote:
> I would like to write a setup.py script for py2app, but I keep bumping
> into an error I don't know how to resolve:
> 
> How do I specify a dependency on PyQt4 ?

First things first: Please specify exactly what versions and builds of 
python, pyqt4 and py2app, and OS-X you are using. All those make a 
difference.

Second: does anyone have a simple qt4 sample that works? WE should have 
one in the py2app SVN -- maybe we do...

Third, I don't use Qt, so i can't help there, but a few general comments:

>  * If I do not tell py2app about the dependency, it successfully
> creates a Mac OS X application package, but fails to run it as it
> cannot find the PyQt4 libraries

The question here is: did pyapp not find the dependency?, or did it not 
include it correctly -- I suspect the second case is what has happened. 
There used to be a "recipe" for pyqt -- I suspect that it it out of 
date, and not working quite right.

Some things to do to investigate:

- start with the very simplest pyqt app you can make -- keep things simpler.

    - before that, start with the simplest python app you can make 
(print "something" should do it), make sure you're dealing with a qt 
problem.

- take a look at the py2app output -- yes, there is a lot, but you'll 
see some hints in there -- maybe search if for "qt4".

- take a look inside the app bundle generated (right click on in to do 
so, or use the command line). By seeing what it in there, you'll get an 
idea what py2app has done.

- take a look at the output generated when you try to start the app -- 
it should show up in the "Console" app.

- You can add some judicious "import sys; print sys.path" statements in 
your app, and see what happens when you run the bundle.

- take a look at the qt recipe that is in the py2app distro -- maybe it 
needs fixing, maybe it isn't being run, 'cause it isn't set up for pyqt4.



>  * If I specify 'PyQt4' as a dependency in setup.py, py2app fails

>     install_requires = [
>         'PyQt4'
>     ],

you've specified it as a dependency to setuptools, not to py2app -- so I 
wouldn't worry about that not working. To tell py2app that you need a 
given package, you do something like:

packages = ['pyQt4']

see the py2app docs. Though I don't think that's your issue.

Anyway, those are all the things I'd do to diagnose the problem.

-Chris

> If that matters: Snow Leopard 10.6.2 w/ full 64 bits installation on a
> MBP Unibody

ooops! OK, I think there are some issues with 64 python and py2app -- do 
some googling of this list for that -- you may need to either fix py2app 
  (or macholib), or use BundleBuilder. You'll see stuff on this list 
about it.

If you don't really need 64bit, I'd just stick with the stock python.org 
32 bit builds -- all this will be much easier.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list