Using Python in IDeATe

The example code for the course includes Python scripts, primarily for controlling hardware via a serial-attached Arduino. The following notes will guide you in getting started on running the examples on the IDeATe cluster laptops.

Python in the IDeATe MBP Cluster

The course primarily supports using the IDeATe cluster MacBook Pro laptops for Python development. However, these laptops have at least three different Python intepreters:

  • MacPorts Python (recommended): /opt/local/bin/python3.5
  • The system Python supplied by Apple: /usr/bin/python
  • An independent Python 3: /usr/local/bin/python3

The standard Python libraries are quite comprehensive but do not include several essential libraries needed for Physical Computing work (notably pySerial). For this reason, the only supported interpreter is the MacPorts installation.

An example of running a course Python script from the command line (e.g. Terminal) might look like this:

$ /opt/local/bin/python3.5 virtual_mpd218.py --help

The initial $ represents the prompt, /opt/local/bin/python3.5 the specific Python interpreter from MacPorts, virtual_mpd218.py is the particular script to run, followed by command-line arguments. In this case, --help will simply print out all possible arguments.

Python in the IDeATe Dell Cluster

The course materials have not yet been tested under Windows 10 on the IDeATe Dell cluster laptops. However, these machines have Anaconda Python 3 installed so in principle should work.

Reference: IDeATe Software.

Python Tutorials

For tutorials: https://www.python.org/about/gettingstarted/

For documentation: https://www.python.org/doc/

For information on third-party packages: https://pypi.python.org/pypi

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.

For beginners, the IDLE editor is recommended. 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

Python 2 versus 3

Python currently exists in two major branches. Python 3 introduced incompatible features, so many projects have continued to use Python 2 for better library support. The situation is slowly resolving as libraries are being ported forward.

The course materials are written in a 2/3 compatible style and but are only tested on Python 3. Currently, 3.5 is recommended for use on the IDeATe laptops but the transition to 3.7 is underway.

For more details on cross-version compatibility, please see Python-Future.

Python on your own laptop

Since we provide the cluster machines, we will not provide support for your personal systems, it is just too labor-intensive. But if you’d like to set one up, please see System Requirements.