Python 3 Installation

Working with the theater performance system will require running Python 3 programs on your own computer. Python is free and open-source, but some examples will require additional open-source packages beyond the stock Python system. The recommended solution is to use the standard distribution from the Python Software Foundation along with a few additional packages.

macOS Installation Notes

To install the standard Python system, please perform the following:

  1. Download a current Python installer from the Python Downloads page.

  2. Open the .pkg file you downloaded to start the installer.

  3. Allow a default install to proceed; it will require a user password for authorization to install into system folders.

  4. Run the Install Certificates.command after installation as recommended by the prompts.

This process will install a working base Python system in /Applications and /Library/Frameworks, with symbolic links in /usr/local/bin.

The additional third-party packages are best installed from the command line (e.g. Terminal.app). Please open a Terminal window and execute the following commands:

pip3 install python-osc
pip3 install scipy
pip3 install mido
pip3 install PyQt6

These packages are also recommended as project resources:

pip3 install opencv-python
pip3 install pyserial
pip3 install python-rtmidi
pip3 install matplotlib
pip3 install scikit-learn

If this is successful, please proceed below to Testing the Installation.

Windows Installation Notes

For a detailed explanation, please see the Python Windows guide in the official Python documentation.

There are many choices available during installation and many possible installation situations, so my instructions may not work exactly the same for you. But the critical objectives are as follows:

  1. The Python installation is included in the system PATH variable. This enables running Python programs from the command line.

  2. The py launcher is installed. The launcher enables running Python programs by double-clicking on .py files.

  3. pip is installed. pip is a convenient tool for installing third-party Python packages, which we’ll need to do after the base install.

With that in mind, the following sequence may help you through installation:

  1. Download a current Python installer from either Python Downloads or Python Windows Downloads. The default installer type is the “x86-64 executable installer”.

  2. Run the .exe file you downloaded to start the installer.

  3. Please enable the checkbox labeled “Add Python..to PATH”.

  4. Select Install Now to proceed. You’ll need to confirm Yes in the User Account Control (UAC) dialog which appears.

  5. After installation on Windows 10, you may be offered the option to Disable path length limit. This generally appears to be a good idea unless you are still developing software for Windows 8 or earlier. You’ll need to confirm Yes to another UAC dialog.

The default install places the base Python system in your AppData folder, e.g. C:\Users\garthz\AppData\Local\Programs\Python\Python311. Some alternate options may place it elsewhere.

We will need several additional packages to run the course software. These third-party packages are most easily installed from the command line, available on Windows as Command Prompt from the Windows System section of the Start Menu, or by typing cmd from the Start Menu Run option. Please open the command line window and type the following:

pip3 install python-osc
pip3 install scipy
pip3 install mido
pip3 install PyQt6

These packages are also recommended as project resources:

pip3 install opencv-python
pip3 install pyserial
pip3 install python-rtmidi
pip3 install matplotlib
pip3 install scikit-learn

If pip3 is not found, then it is likely Python was not added to the system PATH environment variable. Some possible fixes for this:

  1. Modify settings by using the Windows Settings panel. Locate Python on the Apps section, select it, then click Modify. Under Optional Features please ensure that pip and the py launcher are enabled. Under Advanced Features you might try enabling ‘Associate files with Python’ and ‘Add Python to environment variables’.

  2. Restart the system.

  3. Re-run the Python installation from scratch.

If you are eventually successful, please proceed below to Testing the Installation.

Testing the Installation

To test the new installation, please try running the interpreter from the command line:

python3

On some installations, it may instead be named python (without the digit):

python

Please check the banner message to verify you’ve run the right version. You may then attempt to import a few packages by typing the following at the intepreter prompt:

import pythonosc
import numpy
import PyQt6
exit()

The result should look generally similar to this transcript. The initial $ is the command shell prompt and the >>> is the Python prompt:

$ python3
Python 3.11.4 (v3.11.4:d2340ef257, Jun  6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pythonosc
>>> import numpy
>>> import PyQt6
>>> exit()

Python Tutorials and References

Some starting points for Python programming:

Third-party packages:

Documentation on some particular packages we may use:

  • python-osc: real-time networked message communication using the Open Sound Control (OSC) standard

  • NumPy: numeric and matrix computations

  • SciPy: scientific algorithms

  • scikit-learn: machine learning

  • PyQt6: GUI and application programming using the Qt6 system

Editing Python

Python is a whitespace-sensitive language in which indentation must be precise. This essentially requires use of a syntax-sensitive programming text editor. We recommend using the Mu Python editor.

Other options include the IDLE editor included with the Python installation. The XCode editor works with Python. Advanced command-line users may enjoy emacs or vim. Many people seem to like the commercial Sublime Text application.

A much longer list can be found at https://wiki.python.org/moin/PythonEditors

Alternative Installations

There are other options for obtaining Python, including the ones listed below. However, only the python.org distribution will be directly supported by the course.

  1. macOS, Windows, Linux: Anaconda Python

  2. macOS: MacPorts Python 3

  3. Ubuntu or Debian Linux: native package system