Re: [Pythonmac-SIG] Installing modules with py2app
Did you build the app bundle with the Python that came with OSX, or did you install a separate Python install from python.org and use that? You have to do the latter; py2app's not allowed to include components of the operating system in the apps it generates. Windows gets around this problem by not having a standard Python install. HTH -Chris On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro alejan...@ti.com wrote: Hello I have a script that installs Python, and then installs some modules with: subprocess.call(python setup.py install) The script works on Windows with py2exe, but gives me this error when using py2app: File setup.py from distutils.core import setup ImportError: No module named distutils.core I tried explicitly including distutils when building the .app bundle, with python setup.py py2app --packages distutils (and several variations of --includes), but then I get this error: error: invalid command 'install' What do I need to do to make this work on mac? Thanks! ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Installing modules with py2app
Hi I am using a separate Python install (ActivePython 2.6 ), so that's not it Thanks -- Alejandro Mier y Concha From: pythonmac-sig-bounces+alejandro=ti@python.org [mailto:pythonmac-sig-bounces+alejandro=ti@python.org] On Behalf Of Chris Weisiger Sent: Tuesday, January 18, 2011 10:08 AM Cc: pythonmac-sig@python.org Subject: Re: [Pythonmac-SIG] Installing modules with py2app Did you build the app bundle with the Python that came with OSX, or did you install a separate Python install from python.orghttp://python.org and use that? You have to do the latter; py2app's not allowed to include components of the operating system in the apps it generates. Windows gets around this problem by not having a standard Python install. HTH -Chris On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro alejan...@ti.commailto:alejan...@ti.com wrote: Hello I have a script that installs Python, and then installs some modules with: subprocess.call(python setup.py install) The script works on Windows with py2exe, but gives me this error when using py2app: File setup.py from distutils.core import setup ImportError: No module named distutils.core I tried explicitly including distutils when building the .app bundle, with python setup.py py2app --packages distutils (and several variations of --includes), but then I get this error: error: invalid command 'install' What do I need to do to make this work on mac? Thanks! ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.orgmailto:Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Installing modules with py2app
Do you have distutils installed? It usually doesn't come bundled with Python. It can be installed with easy_install: easy_install distutils Cheers, João On Tue, Jan 18, 2011 at 4:27 PM, Mier, Alejandro alejan...@ti.com wrote: Hi I am using a separate Python install (ActivePython 2.6 ), so that’s not it Thanks -- Alejandro Mier y Concha From: pythonmac-sig-bounces+alejandro=ti@python.org [mailto:pythonmac-sig-bounces+alejandro=ti@python.org] On Behalf Of Chris Weisiger Sent: Tuesday, January 18, 2011 10:08 AM Cc: pythonmac-sig@python.org Subject: Re: [Pythonmac-SIG] Installing modules with py2app Did you build the app bundle with the Python that came with OSX, or did you install a separate Python install from python.org and use that? You have to do the latter; py2app's not allowed to include components of the operating system in the apps it generates. Windows gets around this problem by not having a standard Python install. HTH -Chris On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro alejan...@ti.com wrote: Hello I have a script that installs Python, and then installs some modules with: subprocess.call(python setup.py install) The script works on Windows with py2exe, but gives me this error when using py2app: File setup.py from distutils.core import setup ImportError: No module named distutils.core I tried explicitly including distutils when building the .app bundle, with python setup.py py2app --packages distutils (and several variations of --includes), but then I get this error: error: invalid command 'install' What do I need to do to make this work on mac? Thanks! ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Installing modules with py2app
On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro alejan...@ti.com wrote: Hello I have a script that installs Python, and then installs some modules with: subprocess.call(python setup.py install) The script works on Windows with py2exe, but gives me this error when using py2app: File setup.py from distutils.core import setup ImportError: No module named distutils.core Try debugging this issue by printing sys.path, and check if distutils/core... exists in one of them: subprocess.call('python -c import sys; print((sys.prefix, sys.path))') -srid ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Installing modules with py2app
Hi Sridhar Your suggestion to debug this problem started me in the right path. I found a workaround for the issue. First, I explicitly included distutils in my py2app bundle. With that, the error I get is: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: invalid command 'install' I modified the included distutils files, and managed to get this stack trace Traceback (most recent call last): File distutils/dist.py, line 837, in get_command_class __import__ (module_name) File distutils/command/install.py, line 21, in module from site import USER_BASE cannot import name USER_BASE The site.py included in the bundle has this comment: This is stripped down and customized for use in py2app applications So apparently, py2app is removing USER_BASE and USER_SITE from site.py. I am not sure why it does that, but it is preventing the installation of modules with py2app. I worked around it by modifying the included site.py to declare USER_BASE and USER_SITE after generating the .app bundle. I think this might be a bug in py2app, but would like to know your input on this. Regards, -- Alejandro Mier y Concha -Original Message- From: Sridhar Ratnakumar [mailto:sridhar.ra...@gmail.com] Sent: Tuesday, January 18, 2011 11:43 AM To: Mier, Alejandro Cc: pythonmac-sig@python.org Subject: Re: [Pythonmac-SIG] Installing modules with py2app On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro alejan...@ti.com wrote: Hello I have a script that installs Python, and then installs some modules with: subprocess.call(python setup.py install) The script works on Windows with py2exe, but gives me this error when using py2app: File setup.py from distutils.core import setup ImportError: No module named distutils.core Try debugging this issue by printing sys.path, and check if distutils/core... exists in one of them: subprocess.call('python -c import sys; print((sys.prefix, sys.path))') -srid ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Installing modules with py2app
On 1/18/11 9:05 AM, João Vale wrote: Do you have distutils installed? It usually doesn't come bundled with Python. huh? Sure it does -- distutils has been standard in Python for many many years. So that's not it. Besides, if you can run it unbundled, you have the packages you need, the question is how to get them properly into the py2app bundle. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Python development on OSX
On 1/17/11 9:17 AM, Bill Janssen wrote: And- I want to update the default python that came om my macbook pro to 2.7. Should I do install that from Python.org? My advice? I've never had good luck trying to update the default Python that comes with the Mac. Bill -- I'm really curious what issues you've had -- I haven't tried to use Apple's Python is many years (OS-X 10.2, I think) -- and it used to be painful to do so. Since then I've stuck with the Python.org versions, and had no problems (at least none that would have been solved by using Apple's Python). Here's my decision tree: 1) Do I do a bunch of unix-y command line stuff in general, and not want to develop OS-X GUIs? if yes -- use Macports if no: Do I need/want a newer version than Apple provides? if yes: python.org build Do I need/want to use py2app to distribute my app(s)? if yes: use the Python.org build Do I want to use pre-build binaries of common hard-to-build packages? if yes: use the python.org build. You can see that most roads lead to the python.org builds. That being said, to be clear: You don't upgrade Apple's python. Rather, you install a new one alongside it, and use that for your work. It is safe to build (and run) a non-Framework build of other versions of Python in various places on your Mac, but life gets complicated if you attempt to install it. Again, I've never had a complication from an installed python.org build. You sure would if you put it in the same place as Apple's but the installers don't do that. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Python development on OSX
Christopher Barker chris.bar...@noaa.gov wrote: On 1/17/11 9:17 AM, Bill Janssen wrote: And- I want to update the default python that came om my macbook pro to 2.7. Should I do install that from Python.org? My advice? I've never had good luck trying to update the default Python that comes with the Mac. Bill -- I'm really curious what issues you've had -- I haven't tried to use Apple's Python is many years (OS-X 10.2, I think) -- and it used to be painful to do so. Since then I've stuck with the Python.org versions, and had no problems (at least none that would have been solved by using Apple's Python). In general, there are issues around site-packages, paths, and other such things. I don't think you and I necessarily have much trouble with it, but I tend to help others with Python on Macs, and they seem to get into all kinds of trouble. The best one I've found is one group who had decided to upgrade their Leopard Python to 2.6. They'd installed the python.org Python, removed the symlink /usr/bin/python, and re-linked /usr/bin/python to the 2.6 version. They were happy, but plagued by odd problems with their machines that didn't (to them) seem to be Python-related. Another problem I've run into more than once was that the user had installed different incompatible versions of an extension, and couldn't see why an application (with an embedded Python interpreter) was misbehaving -- it was getting the wrong version of the extension. Not sure this is much use to anyone, but here's my decision tree, which has worked well for me over the past 7 years: 1) Do I do a bunch of unix-y command line stuff in general, and not want to develop OS-X GUIs? if yes -- use system Python. if no: Do I need/want a newer version than Apple provides? if yes: build non-framework version from source. Do I need/want to use py2app to distribute my app(s)? Never happens. Do I want to use pre-build binaries of common hard-to-build packages? if yes: cry about the general unfairness of the world, then build them from source instead to work with the system Python. Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Installing modules with py2app
On 1/18/11 2:47 PM, Mier, Alejandro wrote: I modified the included distutils files, and managed to get this stack trace Traceback (most recent call last): File distutils/dist.py, line 837, in get_command_class __import__ (module_name) File distutils/command/install.py, line 21, inmodule from site import USER_BASE cannot import name USER_BASE The site.py included in the bundle has this comment: This is stripped down and customized for use in py2app applications So apparently, py2app is removing USER_BASE and USER_SITE from site.py. I am not sure why it does that, but it is preventing the installation of modules with py2app. I worked around it by modifying the included site.py to declare USER_BASE and USER_SITE after generating the .app bundle. I think this might be a bug in py2app, but would like to know your input on this. I don't think it's a bug -- you may have some problems with this. I'm not sure I quite get what distutils is doing with USER_BASE and USER_SITE, but I suspect that they are using them to figure out where to install stuff. That should be a function of the python you are installing to. A py2app bundle isn't usually installing stuff into itself. How are you using distutils in this case? Are you installing stuff into the app bundle? Or into a system python? If a system python, you should probably use the system python's distutils (and thus its site.py) to do the work. If you are installing into the app bundle (cool idea!), then you'll need to make sure that USER_BASE and USER_SITE are set correctly at run time for where the user happens to have put the py2app bundle. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG