[Pythonmac-SIG] python and py2app help
Nathan Lemoine
lemoine.nathan at gmail.com
Fri Jul 23 07:46:14 CEST 2010
Hi,
I was wondering if someone could help me with a problem I'm having
bundling my python script (originally built with the 2.5 version of
Python that ships with OS X 10.5) with py2app. I've basically run
through all the online help I can find on how to make it work (several
times) and nothing has worked out.
First, I tried running py2app following the Tutorial here: http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html
.
I received this error message:
Traceback (most recent call last):
File "/usr/local/bin/py2applet", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.5/
Extras/lib/python/pkg_resources.py", line 2607, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.5/
Extras/lib/python/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: macholib>=1.3
So I figured the macholib library wasn't installed, so after some
looking around i found this tutorial: http://aralbalkan.com/1675
so I followed it to the letter and received an error message that
py2app couldn't find the modulegraph package >= 0.7.3, but I know I
had installed a higher version.
So things got even more confusing (for me), because I went into the
python.org website and downloaded the 2.7 version of MacPython
(thinking that might help). As soon as I did that, my script would no
longer run from the shell, as it could not find any of the modules I
had installed. After calling sys.path, I could see that it wasn't
searching the proper paths for any of my 2.5 frameworks. In fact,
searching my computer, I couldn't find the 2.5 frameworks anywhere.
So then I uninstalled macports, reinstalled the modules (wxPython,
PIL, pyglet, and others), reinstalled macports, etc. etc.
Unfortunately, pyglet installed itself somewhere odd (and I have no
idea why) and I haven't figured out how to get the new version of
python (2.7) to permanently add its new path to sys.path. I've tried
sys.path.append, but that doesn't seem to be a permanent fix. The
other modules (wx, PIL) seem to have installed fine. Moreover, running
the 'which python' command used to get me /usr/bin/python and now
returns '/Library/Frameworks/Python.framework/Versions/2.7/bin/python'.
So it gets stranger (to me). Following the py2app tutorial stills nets
me an error message about macholib. Manually creating the setup.py
file and calling py2app from within the python interpreter (per Aral
Balkan's guide) doesn't get me any error messages about py2app, and
the app actually does get built. Except it doesn't run because when I
click on it, I get an error message about not being able to import the
pyglet module. Also, I use TextWrangler for writing my scripts, and
whenever I execute the script from within TextWrangler (via the
program itself or by Terminal via TextWrangler), the script works
great! So clearly TextWrangler is calling a different version of
python (likely the original version 2.5 from \usr\bin\python?) that
actually has the modules I need, but I could never get py2app to work
in version 2.5, and when I installed MacPython, it seems to have
overwritten 2.5 because now I can only initiate 2.7 in the shell,
which then gets me error messages about importing modules.
So my computer (and myself) is very confused about what version of
Python is actually installed and operating from the shell or from
TextWrangler. Additionally, regardless of version, I've never been
able to get py2app to actually function. I have no idea where my 2.5
frameworks went, but they are still there, clearly, because
TextWrangler calls them. I don't know how to force Terminal to open
the \usr\bin\python version of python instead of the new version.
I'm very new to programming and working with python and modules, etc
(less than a week). I've written a pretty nice GUI program for having
less than a week of experience, and all I'm trying to do is bundle it
into an app. So I've learned what I could by following tutorials and
instructions online, but now I feel that I've installed so many things
following these tutorials that it's sort of confusing the whole
system. Is there a way to basically just revert on back to a clean
install of python and starting over? Or can someone help me get py2app
to actually work from version 2.7/get version 2.7 to find my pyglet
module. I feel like if I can solve that one problem it may actually
build OK, despite the rather large mess I seem to have made of installs.
I'm also very confused as to why TextWrangler can operate my script,
or open termina (again, likely using the \usr\bin\python versionl,
which then operates my script, whereas manually running the script
from Terminal via python script.py gets me error messages about
importing modules.
More information about the Pythonmac-SIG
mailing list