Greg Roberts
Greg Roberts

Reputation: 13

Create standalone applications with py2app by not using the system installation of Python on Mac?

I am using py2app to package a Python application to be used on other Mac computers. I am currently running OSX 10.7.5 and the system Python installation on my computer is Python 2.7.1. When I package the program with py2app, it works on my computer, but will not work on another computer - the error that comes up is it cannot locate a Python runtime.

From what I have read about this, it looks like my py2app build is using the system installation of Python on my computer and therefore will only create a semi-standalone application instead of a standalone application.

Also, I have seen that to fix this you need to package it with a separately downloaded Python. I have downloaded a separate Python and even tried to change my PYTHONPATH in my .bash_profile file, but cannot seem to get py2app to build with a different version of Python.

Can anyone point me in the right direction as to how to do this?

I have read other questions and wasn't able to find out how to do it in my case. If there is any other information you need to know to help, please let me know.

Upvotes: 1

Views: 1525

Answers (2)

taynaron
taynaron

Reputation: 730

The simplest way of handling this IMO is by utilizing MacPorts. You can download and install a standalone version of Python and just about any other package you might need.

  1. Get macports: https://www.macports.org
  2. sudo port install py27-py2app
  3. sudo port select python python27

Now your standalone Python is the default, and py2app will run and bundle using that version of Python.

Upvotes: 0

Ronald Oussoren
Ronald Oussoren

Reputation: 2810

py2app builds the application bundle using the running version of python. To use the separate install of python you therefore have to make sure that py2app and the other libraries you use are available in that installation of Python, then use that installation to build the application.

For example:

$ /Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install py2app
$ .../bin/easy_install ...
$ /Library/Frameworks/Python.framework/Versions/2.7/bin/python setup.py py2app

Upvotes: 1

Related Questions