Python Distribution

Python Distribution is another important method used in this programming language. As a programmer, you can find out more about this method here.


To use the py2app framework you must install it first. Do this by opening terminal and entering the following command:

sudo easy_install -U py2app

You can also pip install the packages as:

pip install py2app

Then create the setup file for your python script:

py2applet --make-setup

Edit the settings of the setup file to your liking, this is the default:

This is a script generated by py2applet
python py2app
from setuptools import setup
APP = ['']
OPTIONS = {'argv_emulation': True}
options={'py2app': OPTIONS},

To add an icon file (this file must have a .icns extension), or include images in your application as reference, change your options as shown:

DATA_FILES = ['myInsertedImage.jpg']
OPTIONS = {'argv_emulation': True, 'iconfile': 'myCoolIcon.icns'}

Finally enter this into terminal:

python py2app

The script should run and you will find your finished application in the dist folder.

Use the following options for more customization:

optimize (-O) optimization level: -O1 for "python -O", -O2 for
"python -OO", and -O0 to disable [default: -O0] – Python® Notes for Professionals 454

includes (-i) packages (-p) extension

comma-separated list of modules to include comma-separated list of packages to include
Bundle extension [ for app, .plugin for plugin]
comma-separated list of additional scripts to include in an application or plugin.

Python Distribution: cx_Freeze

Install cx_Freeze from here

Unzip the folder and run these commands from that directory:

python build
sudo python install

Create a new directory for your python script and create a “” file in the same directory with the following content:

application_title = "My Application" # Use your own application name main_python_file = "" # Your python script
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
includes = ["atexit","re"]
name = application_title,
version = "0.1",
description = "Your Description",
options = {"build_exe" : {"includes" : includes }}, executables = [Executable(main_python_file, base = base)])

Now run your from terminal:

python bdist_mac

NOTE: On El Capitan this will need to be run as root with SIP mode disabled.

Read more


Please enter your comment!
Please enter your name here