Because students bring their own laptops and devices I’ve had some trouble in the past getting everyone running python with the packages I typically use (mainly vpython). This is a quick reference about how to get up and running on Windows, OSX, and Linux.
Linux
These should be pretty identical. Ultimately, students may want to learn how to set up virtual environments (e.g. venv), however, for our purposes python3 should already be installed.
Using a Terminal window we’ll install pip:
sudo apt install python3-pip
and use pip to install vpython (which should install numpy as a dependency).
pip3 install vpython
and finally matplotlib:
pip3 install -U matplotlib
Test the installation by running python3 and making a sphere. Run:
python3
In the interpreter enter the two lines:
from vpython import *
sphere()
A new browser tab should pop up with a sphere (Figure 1).
OSX
OSX should be very similar to the Linux installation. You may have to install the latest version of python from https://www.python.org/downloads/, but you can check to see if python3 is installed by typing into a Terminal window:
python3
which will start the interpreter if python3 is installed.
Windows
Download and install the latest version of python (3.9 at the moment) from https://www.python.org/downloads/ . I then followed the instructions on Installing Packages for Windows.
The following commands will be run using the Command Prompt application:
First check that python is installed (and which version it is):
py --version
which should show something like (if it does not then something probably went wrong with the installation):
Python 3.9.7
Now install and upgrade pip (and setuptools and wheel):
py -m pip install --upgrade pip setuptools wheel
Install vpython (which includes numpy)
py -m pip install vpython
And matplotlib:
py -m pip install matplotlib
Test by opening the IDLE App, and at the interpreter prompt typing the two lines:
from vpython import *
sphere()
and you should see Figure 1 pop up in a new browser tab.