[Pythonmac-SIG] Py2app error

Chris Barker chris.barker at noaa.gov
Thu Aug 2 17:58:47 CEST 2012


On Wed, Aug 1, 2012 at 10:39 PM, Mark Livingstone
<livingstonemark at gmail.com> wrote:

> OK, taking Chris' advice, I installed on a Snow Leopard machine:

now that you've named, me, I feel compelled to contiue to help.. ;-)

> cheyenne:dist marklivingstone$ ls ~/Downloads/
> About Downloads.lpdf
> numpy-1.6.2-py2.7-python.org-macosx10.3.dmg
> wxMac-2.8.12.tar
> matplotlib-1.1.0-py2.7-python.org-macosx10.3.dmg
> python-2.7.3-macosx10.6.dmg

Careful here: Thanks to Apple's fast-moving development ( 4!
architectures potentially in the wild -- PPC32+64bit, Intel 32+64 bit)
it's hard to have something for eveyting...

note that you have

"numpy-1.6.2-py2.7-python.org-macosx10.3.dmg"
but
"python-2.7.3-macosx10.6.dmg"

we put the really long name in the numpy installer to try to make this
clear, but it really gets complicated fast...

Anyway, on the pyton,org site, there are:

Python 3.2.3 Mac OS X 64-bit/32-bit x86-64/i386 Installer (for Mac OS
X 10.6 and 10.7)

and

Python 3.2.3 Mac OS X 32-bit i386/PPC Installer (for Mac OS X 10.3 through 10.6)

These are what they seem to be -- though I think you got tripped up by
"for Mac OS X 10.3 through 10.6"  -- actually, that should be "10.3 +
" -- 10.7 didn't exist when that was built.

The numpy and wx packages you have are built for the "10.3" installer.

The release version of wx doesn't support 64 bit Intel (though it does
support 32 bit intel).


> wxPython2.8-osx-docs-demos-2.8.12.1-universal-py2.7.dmg
> mercurial-2.2.3_20120707-py2.7-macosx10.7

this looks like it may be for the newer installer.

> scipy-0.11.0rc1-py2.7-python.org-macosx10.6.dmg

this also -- so your scipy and numpy are out of sync, too!

> wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg

this is for the "10.3" 32 bit binary.

What a mess!

You have two options:

1) Use the "10.6" python binary (intel 32+64 bit), then get all the
packages compatible with that. IN this case, the trick will be wx. You
can:

  a) Make sure you run the binary in 32 bit mode (Not 64), and it
should work, but it's a bit messy to make sure that all works right.

  b) Use a new development build of wx (wx2.9.*) -- there is a 64 bit
Cocoa build available - but it does a few changes, so will take a bit
of work to port to.


2) (probably the easiest) -- use the 32bit 10.3+ build of Python --
then make sure all your other packages are built for that -- hopefully
you can find a Mercurial package for it -- the rest are there. (it may
not be hard to build mercurial, either, does it have any
dependencies?)

Sorry for the mess -- blame Apple!

> I tried a build but got this:
>
>  python ../mac-setup/setup_py2app.py py2app
> Traceback (most recent call last):
>   File "../mac-setup/setup_py2app.py", line 1, in <module>
>     import wx
>   File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/__init__.py",
> line 45, in <module>
>     from wx._core import *
>   File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core.py",
> line 4, in <module>
>     import _core_
> ImportError: dlopen(/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core_.so,
> 2): no suitable image found.  Did find:
>         /usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core_.so:
> no matching architecture in universal wrapper

Well -- no ;point in going beyond this -- wx isn't working. What
you've got is a a 32 bit PPC+Intel wx, but you're running a 32+64 bit
Python -- and it defaults to 64 bit on a 64 bit machine -- so it's
looking for a 64bit Intel binary of wx -- which is not there.

> However, when I try to run the app, I get the following in the console log:
> ImportError: dlopen(/Users/marklivingstone/Documents/workspace/salstat-statistics-package-2/src/dist/SalStat.app/Contents/Resources/lib/python2.7/lib-dynload/wx/_core_.so,
> 2): no suitable image found.  Did find:

same error -- no surprise there -- if it doesn' work outside of
py2app, it won't work with it.

> Is it just not possible to use py2app to create an app for the Mac based on wx?

indeed it is -- I'm doing it with most of the same stuff you are
(except Mercurial) (using the 32 bit build)


NOTE: I'm considering building a custom 32bit Intel (10.4+, maybe)
only distribution for the Mac -- it would run on any recent system,
and be smaller to bundle, etc.

Or maybe 64 bit -- how common are 32 bit only Intel Mac these days --
anyone know?

> Also, the final result turns in at 184MB in size. Are there any common
> things that may be being pulled in that I should exclude?

Well, that's a trick. It's going to be big -- you've got multiple
binaries in there for different architectures -- so all the binary
stuff is doubled. Then you've got packages that bring the world in
with them:

wx is big -- not much to be done about that though you may be able to
pull out an so or two.)

numpy default imports a bunch of stuff like ffts, lapack, etc that you
may or may not be using, but it needs to be there on import.

scipy brings in all sort of stuff you probably aren't using -- if
you're only using a couple things from scipy, it may be worth
extracting just those by hand before py2app-ing -- but native scipy is
a bit entangled with imports.

matplotlib needs data files, so py2app by defualt brings the whole
package in -- again, you may well not need all that.


Unfortunately, package maintainers dont generally see making their
packages compatible with py2app, y2exe, etc as a priority -- so it's
easiest to just accept the monster app -- disk space is cheap (even if
bandwidth is not as cheap).

-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