Web Analytics Made Easy - Statcounter
Skip to content

Installation

Of course if you're installing for Qt, WxPython, Web, you'll use PySimpleGUIQt, PySimpleGUIWx, and PySimpleGUIWeb instead of straight PySimpleGUI in the instructions below. You should already have the underlying GUI Framework installed and perhaps tested. This includes tkinter, PySide2, WxPython, Remi

Installing on Python 3

pip install --upgrade PySimpleGUI

On some systems you need to run pip3. (Linux and Mac)

pip3 install --upgrade PySimpleGUI

On a Raspberry Pi, this is should work:

sudo pip3 install --upgrade pysimplegui

Some users have found that upgrading required using an extra flag on the pip --no-cache-dir.

pip install --upgrade --no-cache-dir PySimpleGUI

On some versions of Linux you will need to first install pip. Need the Chicken before you can get the Egg (get it... Egg?)

sudo apt install python3-pip

tkinter is a requirement for PySimpleGUI (the only requirement). Some OS variants, such as Ubuntu, do not some with tkinter already installed. If you get an error similar to:

ImportError: No module named tkinter

then you need to install tkinter.

For python 2.7

sudo apt-get install python-tk

For python 3 sudo apt-get install python3-tk

More information about installing tkinter can be found here: https://www.techinfected.net/2015/09/how-to-install-and-use-tkinter-in-ubuntu-debian-linux-mint.html

Installing typing module for Python 3.4 (Raspberry Pi)

In order for the docstrings to work correctly the typing module is used. In Python version 3.4 the typing module is not part of Python and must be installed separately. You'll see a warning printed on the console if this module isn't installed.

You can pip install typing just like PySimpleGUI. However it's not a requirement as PySimpleGUI will run fine without typing installed as it's only used by the docstrings.

Installing for Python 2.7

IMPORTANT PySimpleGUI27 will disappear from the GitHub on Dec 31, 2019. PLEASE migrate to 3.6 at least. It's not painful for most people.

pip install --upgrade PySimpleGUI27 or pip2 install --upgrade PySimpleGUI27

You may need to also install "future" for version 2.7

pip install future or pip2 install future

Like above, you may have to install either pip or tkinter. To do this on Python 2.7:

sudo apt install python-pip

sudo apt install python-tkinter

Upgrading from GitHub Using PySimpleGUI

There is code in the PySimpleGUI package that upgrades your previously pip installed package to the latest version checked into GitHub.

It overwrites your PySimpleGUI.py file that you installed using pip with the currently posted version on GitHub. Using this method when you're ready to install the next version from PyPI or you want to maybe roll back to a PyPI release, you only need to run pip.

The PySimpleGUI "Home Window"

If you call sg.main() then you'll get the Home Window and can use the upgrade feature.

import PySimpleGUI as sg
sg.main()

After you've pip installed, you can use the commands psgmain to run the Home Window or psgupgrade to invoke the GitHub upgrade code.

There have been problems on some machines when psgmain and psgupgrade are used to upgrade PySimpleGUI. The upgrade is in-place so there can be file locking problems. If you have trouble using these commands, then you can also upgrade using this command:

python -m PySimpleGUI.PySimpleGUI upgrade

The "Safest" approach is to call sg.main() from your code and then click the red upgrade button.

sg main()

Recovering From a Bad GitHub Release

If you run into a problem upgrading after upgrading from GitHub, you can likely use pip to uninstall, then re-install from PyPI to see if you can upgrade again from GitHub.

pip uninstall PySimpleGUI
pip install PySimpleGUI

Testing your installation and Troubleshooting

Once you have installed, or copied the .py file to your app folder, you can test the installation using python.

The Quick Test

The PySimpleGUI Home Window pictured in the previous section on GUI upgrades is the short program that's built into PySimpleGUI that serves multiple purposes. It exercises many/most of the available Elements, displays version and location data and works as a quick self-test.

psgmain is a command you can enter to the run PySimpleGUI Home Window if you pip installed. You can also use:

From your command line type: python -m PySimpleGUI.PySimpleGUI

If you're on Linux/Mac and need to run using the command python3 then of course type that.

This will display the Home Window window.

You can also test by using the REPL....

Instructions for Testing Python 2.7:

>>> import PySimpleGUI27
>>> PySimpleGUI27.main()

Instructions for Testing Python 3:

>>> import PySimpleGUI
>>> PySimpleGUI.main()

You will see a "Home Window" that exercises the SDK, tells you the version number, allows you to try a number of features as well as access the built-in GitHub upgrade utility.

Finding Out Where Your PySimpleGUI Is Coming From

It's critical for you to be certain where your code is coming from and which version you're running.

Sometimes when debugging, questions arise as to exactly which PySimpleGUI you are running. The quick way to find this out is to again, run Python from the command line. This time you'll type:

>>> import PySimpleGUI as sg
>>> sg

When you type sg, Python will tell you the full patch to your PySimpleGUI file / package. This is critical information to know when debugging because it's really easy to forget you've got an old copy of PySimpleGUI laying around somewhere.

Finding Out Where Your PySimpleGUI Is Coming From (from within your code)

If you continue to have troubles with getting the right version of PySimpleGUI loaded, THE definitive way to determine where your program is getting PySimpleGUI from is to add a print to your program. It's that simple! You can also get the version you are running by also printing

import PySimpleGUI as sg

print(sg)
print(sg.version)

Just like when using the REPL >>> to determine the location, this print in your code will display the same path information.

Manual installation

If you're not connected to the net on your target machine, or pip isn't working, or you want to run the latest code from GitHub, then all you have to do is place the single PySimpleGUI source file PySimpleGUI.py (for tkinter port) in your application's folder (the folder where the py file is that imports PySimpleGUI). Your application will load that local copy of PySimpleGUI as if it were a package.

Be sure that you delete this PySimpleGUI.py file if you install a newer pip version. Often the sequence of events is that a bug you've reported was fixed and checked into GitHub. You download the PySimpleGUI.py file (or the appropriately named one for your port) and put with your app. Then later your fix is posted with a new release on PyPI. You'll want to delete the GitHub one before you install from pip.