By Teifion

2008-08-05 22:26:00 8 Comments

Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux.

The problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?


@lubos hasko 2008-08-05 22:34:25

First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.

Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)

Of course, there are many, but the most popular that I've seen in wild are:

Complete list is at

Single executable (all platforms)

  • PyInstaller - the most active(Could also be used with PyQt)
  • fbs - if you chose Qt above

Single executable (Windows)

  • py2exe - used to be the most popular

Single executable (Linux)

  • Freeze - works the same way like py2exe but targets Linux platform

Single executable (Mac)

  • py2app - again, works like py2exe but targets Mac OS

@changelog 2008-10-15 03:15:08

Talk about pyinstaller for windows, instead of py2exe.

@CTT 2009-02-20 07:28:29

It's worth noting that as of 4.5 QT will be under the LGPL.

@Chris Morgan 2010-12-07 00:35:45

... which is why you should now very much consider using PySide which is LGPL. It's also more Pythonic than PyQt4's Python 2 API.

@fbmd 2012-02-16 07:54:20

You might also add cx_Freeze, which is cross-platform, maintained, and supports Python 3.x.

@SilSur 2018-10-02 14:04:11

Why is there no mention of Kivy here? Is it not a valid option for this question?

@Javad Norouzi 2020-05-19 23:14:53

I tried to build exe on ubuntu 18.4 for windows with py2exe but it's only for building on windows. you can't build from other OSes. Instead I decided to use pyinstaller

@Ritveak 2020-01-10 07:24:51

!!! KIVY !!!

I was amazed seeing that no one mentioned Kivy!!!

I have once done a project using Tkinter, although they do advocate that it has improved a lot, it still gives me a feel of windows 98, so I switched to Kivy.

I have been following a tutorial series if it helps...

Just to give an idea of how kivy looks, see this (The project I am working on):

The Project that I am working on

And I have been working on it for barely a week now ! The benefits for Kivy you ask? Check this

The reason why I chose this is, its look and that it can be used in mobile as well.

@MikeyB 2018-10-09 12:30:07

PySimpleGUI wraps tkinter and works on Python 3 and 2.7. It also runs on Qt, WxPython and in a web browser, using the same source code for all platforms.

You can make custom GUIs that utilize all of the same widgets that you find in tkinter (sliders, checkboxes, radio buttons, ...). The code tends to be very compact and readable.

#!/usr/bin/env python
import sys
if sys.version_info[0] >= 3:
    import PySimpleGUI as sg
    import PySimpleGUI27 as sg

layout = [[ sg.Text('My Window') ],
          [ sg.Button('OK')]]

window = sg.Window('My window').Layout(layout)
button, value = window.Read()

Image created from posted PySimpleGUI code

As explained in the PySimpleGUI Documentation, to build the .EXE file you run:

pyinstaller -wF

@Giovanni G. PY 2017-01-31 19:51:42

# I'd use tkinter for python 3

import tkinter

tk = tkinter.Tk()
l = Label(tk,text="")
e = Entry(tk)

def click():
    e['text'] = 'You clicked the button'

b = Button(tk,text="Click me",command=click)


# After this I would you py2exe
# search for the use of this module on stakoverflow
# otherwise I could edit this to let you know how to do it


Then you should use py2exe, for example, to bring in one folder all the files needed to run the app, even if the user has not python on his pc (I am talking of windows... for the apple os there is no need of an executable file, I think, as it come with python in it without any need of installing it.

Create this file

1) Create a

with this code:

from distutils.core import setup
import py2exe


save it in a folder

2) Put your program in the same folder of put in this folder the program you want to make it distribuitable: es:

ps: change the name of the file (from l4h to anything you want, that is an example)

3) Run cmd from that folder (on the folder, right click + shift and choose start cmd here)
4) write in cmd:>python py2exe
5) in the dist folder there are all the files you need
6) you can zip it and distribute it


Install it from cmd


pip install pyinstaller


Run it from the cmd from the folder where the file is




@shahar_m 2017-06-08 10:21:11

You can use appJar for basic GUI development.

from appJar import gui


def myfcn(btnName):   
    global num
    num +=1
    win.setLabel("mylabel", num)

win = gui('Test')

win.addButtons(["Set"],  [myfcn])
win.addLabel("mylabel", "Press the Button")


GUI when running

See documentation at appJar site.

Installation is made with pip install appjar from command line.

@Jamie 2008-08-28 08:41:45

Another system (not mentioned in the accepted answer yet) is PyInstaller, which worked for a PyQt project of mine when py2exe would not. I found it easier to use.

Pyinstaller is based on Gordon McMillan's Python Installer. Which is no longer available.

@Dave 2011-11-10 19:57:28

And more than 3 years after this was answer was written, pyinstaller STILL does not support Python 3, nor is it listed in the roadmap of future releases. I mean, is AIX and Solaris support really more useful than Python 3?

@Katu 2016-03-05 19:13:44

It supports Python 2.7 and Python 3.3, 3.4 and 3.5 now.

@Rexcirus 2017-10-14 13:01:22

And 3.6 too now.

@Tofystedeth 2008-11-05 15:53:19

There's also PyGTK, which is basically a Python wrapper for the Gnome Toolkit. I've found it easier to wrap my mind around than Tkinter, coming from pretty much no knowledge of GUI programming previously. It works pretty well and has some good tutorials. Unfortunately there isn't an installer for Python 2.6 for Windows yet, and may not be for a while.

@fulmicoton 2008-08-19 09:45:44

For the GUI itself:

PyQT is pretty much the reference.

Another way to develop a rapid user interface is to write a web app, have it run locally and display the app in the browser.

Plus, if you go for the Tkinter option suggested by lubos hasko you may want to try portablepy to have your app run on Windows environment without Python.

@Brian Warshaw 2008-08-15 12:00:37

I'm not sure that this is the best way to do it, but when I'm deploying Ruby GUI apps (not Python, but has the same "problem" as far as .exe's are concerned) on Windows, I just write a short launcher in C# that calls on my main script. It compiles to an executable, and I then have an application executable.

@Adam Lassek 2008-08-18 14:38:31

@Brian Have you seen _why's technique for self-executing Shoes apps? It could probably be done with non-Shoes programs.

@Brian Warshaw 2010-03-03 02:57:29

For these apps, none of my users are anonymous. I know if they have the runtime, and if they don't, I can install it for them. The principal concern in this topic is how to launch these applications without having to open up a command prompt and type the runtime's executable followed by the program name.

@Michael Twomey 2008-08-15 11:56:02

An alternative tool to py2exe is bbfreeze which generates executables for windows and linux. It's newer than py2exe and handles eggs quite well. I've found it magically works better without configuration for a wide variety of applications.

@Matthew Schinckel 2008-08-06 00:29:36

Since python is installed on nearly every non-Windows OS by default now, the only thing you really need to make sure of is that all of the non-standard libraries you use are installed.

Having said that, it is possible to build executables that include the python interpreter, and any libraries you use. This is likely to create a large executable, however.

MacOS X even includes support in the Xcode IDE for creating full standalone GUI apps. These can be run by any user running OS X.

@Justin Standard 2008-08-05 22:40:17

You don't need to compile python for Mac/Windows/Linux. It is an interpreted language, so you simply need to have the Python interpreter installed on the system of your choice (it is available for all three platforms).

As for a GUI library that works cross platform, Python's Tk/Tcl widget library works very well, and I believe is sufficiently cross platform.

Tkinter is the python interface to Tk/Tcl

From the python project webpage:

Tkinter is not the only GuiProgramming toolkit for Python. It is however the most commonly used one, and almost the only one that is portable between Unix, Mac and Windows

@Craig McQueen 2009-07-03 01:43:49

So how would you make an installation package to deploy on systems of people who just want a 1-step install (e.g. double-click on a single installation package in Windows)?

@Justin Standard 2009-07-07 22:14:09

For that there are a few approaches I know of: you would likely write an installer in batch script or compiled for the target system which would drop the needed files someplace and install the needed libraries and runtimes in the process.

@Jonathan Hartley 2009-10-20 17:52:12

Installing Python as part of your own install would be a little fiddly, because you would have to deal with the possibility of the wrong version of Python already being installed. You'd have to install side by side, such that your application could access the newly-installed version of Python, but any existing applications continued to use the old version of Python. (ie without messing up things like the .py file association or the PATH)

@Justin Standard 2009-10-20 23:08:51

More likely your installer would check for the existence of the right version of Python, and if it found it, use that, otherwise install python as a part of the install process.

@Jonathan Hartley 2010-07-09 12:54:33

Right - but that second option 'otherwise install python as a part of the install process', is exactly what I'm talking about. That would be fiddly, for the reasons I gave.

@gaborous 2013-08-08 00:37:23

Or just make an installer which will install a Python distribution bundled with the libraries you need, like Python(x,y) (only for Windows and Linux), or Enthought Canopy Express (for Linux, Windows and MacOSX).

Related Questions

Sponsored Content

25 Answered Questions

[SOLVED] How can I safely create a nested directory?

31 Answered Questions

[SOLVED] How do I get time of a Python program's execution?

29 Answered Questions

[SOLVED] How can you profile a Python script?

35 Answered Questions

[SOLVED] How can I reverse a list in Python?

  • 2010-10-15 06:59:39
  • Leo.peis
  • 1486733 View
  • 1043 Score
  • 35 Answer
  • Tags:   python list

10 Answered Questions

[SOLVED] How can I do a line break (line continuation) in Python?

39 Answered Questions

[SOLVED] How do I create a constant in Python?

  • 2010-04-21 12:20:18
  • zfranciscus
  • 997018 View
  • 1007 Score
  • 39 Answer
  • Tags:   python constants

43 Answered Questions

[SOLVED] How can I represent an 'Enum' in Python?

19 Answered Questions

[SOLVED] How can I use threading in Python?

Sponsored Content