I made a wxPython app for Mac and packaged it with py2app. Two people have already said they can’t get it to launch, with the following error message:
ImportError: dlopen(/Users/username/Desktop/MCManager.app/Contents/Resources/lib/python2.6/wx/_core_.so, 2): Library not loaded: /usr/lib/libwx_macud-2.8.0.dylib
Referenced from: /Users/username/Desktop/MCManager.app/Contents/Resources/lib/python2.6/wx/_core_.so
Reason: image not found
I have only been able to test the app on Mac 10.6.7. Both of the people having the problem are using 10.7.x. Has anyone else had this issue, or know what it means? It seems from the message that it’s trying unsuccessfully to load the wx library, but the wx library should be in the app
s Resources folder, correct?
Here’s my setup file:
#! /usr/bin/env python
import py2app
from setuptools import setup
setup(
options = dict(
py2app = dict(
iconfile = 'MCManager.icns',
packages = 'wx',
site_packages = True,
plist = dict(
CFBundleName = "MCManager",
CFBundleShortVersionString = "1.2.2",
CFBundleGetInfoString = "MCManager 1.2.2",
CFBundleExecutable = "MCManager",
CFBundleIdentifier = "net.sourceforge.mcmanager",
),
),
),
app = ['ScriptUnix.py']
)
I run it with arch -i386 python26 filename.py py2app, (arch because I can’t get Python to run 32-bit without arch, and 2.6 because, very very long story short, I can’t use 2.7 with py2app).
The problem is that you’re building a semi-standalone app. As the docs explain in various places, if you’re using a “vendor Python”, meaning any of the Python versions that came pre-installed with OS X,
py2appcannot build a standalone app. For example:So, it does not package up the
wxlibraries in/usr/lib, because those are vendor libraries. Instead, it just links to the existing ones. There are no such libraries on a standard OS X 10.7 system. Even if there were, the fact that you end up explicitly linking to the 2.8.0 version from 10.6 means it probably wouldn’t work on later systems.What you need to do is to get those
wxlibraries copied into your.appbundle, and reference them from there. Andpy2appwill not do that for you if you run it with your vendor Python. Which means you have three choices:py2appinto building a standalone app anyway, possibly by hacking up thepy2appsources.The best answer is usually #1. In your comments, you say that you were able to install Python 2.7.3 (presumably from python.org?), and you were able to install
py2appfor the vendor 2.6, but that you weren’t able to installpy2appfor the custom 2.7.3. That sounds highly implausible. (If you were able to install 2.7.3 somehow, it should be installed into directories that you have access to.) But, even if it’s true, it doesn’t matter; you can install Python packages into a user-specific site-packages directory, under your home directory. You don’t need admin rights for that. And in fact, most Unix software is designed to work that way.An even easier way to do that is to use virtualenv. Yes, I know, you can’t install it, but you don’t have to. If you read the docs, there’s even a whole set of instructions on how to bootstrap a virtualenv on a system where you can’t install anything. The result is your own personal Python installation, based on the system 2.7.3, but that you have total control over. So you can install
py2appthere. (There are a few notes about usingpy2appandvirtualenvtogether, which you should read about in thepy2appdocs.)If you can’t or won’t do any of those things, then
py2appcan’t do what you want, at least not out of the box. But it’s open source. And there are even comments in the source explaining why it doesn’t try to make standalone builds from system Python. And most of the really tricky stuff is separated out into separate packages (likemacholibandaltgraph), so you should be able to understandpy2appitself, well enough to hack together a standalone package that works for your specific app. (That’s a lot easier than modifyingp2appto fix the underlying problem in a fully general way.)Or you could look at other tools that do similar things as py2app. Try searching PyPI for py2app or freeze and see what comes up. You can generally install packages into your home directory, or run them without installing them, so start playing with whatever looks promising and see if it solves your problem.