Getting Started
These instructions are for installing the necessary tools and Python components for this course. We use the Python.org distribution of Python, but if you already have another distribution, such as Anaconda, that will work fine as long as it includes Python >= 3.7, pip
, and venv
.
Ubuntu/WSL2
If you are using Windows 10 or 11, install WSL2, the Windows Subsystem for Linux, Version 2. WSL2 provides a very nice Linux environment, including a full Linux kernel and distribution of your choosing (I will use the latest Ubuntu in demonstrations).
If you have trouble installing WSL2, you most likely need to update your Windows installation. If you still have trouble, perhaps because you are prevented from updating your computer by an IT department, you can install the Windows version of Python and all the other tools used in this course using the instructions for Windows below. Python is primarily a Linux/Unix technology, and knowledge of Linux is essential for most modern software development, so I recommend installing WSL2 and becoming familiar with Linux, but you will not miss anything in this course by running the Windows versions of Python and the other tools we’ll use.
Install WSL2 (See detailed instructions at https://docs.microsoft.com/en-us/windows/wsl/install-win10#simplified-installation-for-windows-insiders. Note that Windows 10 with all updates from 2021-07-29 and later should support the simplified install.)
- Start PowerShell in admin mode by typing Windows+R, typing
powershell
in the text box, and running it with Ctrl-Enter. - On the PowerShell command line, enter
wsl --install
. Accept the defaults to install the latest version of Ubuntu LTS. - Install Windows Terminal: https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701
Now you have WSL and a very nice terminal installed. In a WSL Ubuntu terminal window, install the necessary Python tools with the commands below (each one on its own line):
sudo apt update
sudo apt upgrade
sudo apt install python3
sudo apt install python3-pip
sudo apt install python3-venv
If your system does not have Python 2 installed, you can make Python 3 “the” Python on your system. You can determine whether Python 2 is installed by trying to run it:
python -V
If you get a message like “command not found” then Python 2 is not installed. Make Python 3 “the’ Python with:
sudo apt install python-is-python3
Now python
and python3
are the same and you don’t have to remember to append 3
to Python commands.
macOS
macOS is a Unix and already has a decent terminal and command-line shell. There are two ways to install Python.org Python (as opposed to Anaconda Python or some other Python distribution).
- Download the macOS installer from python.org.
or
Install Homebrew and use Homebrew to install Python:
brew install python3
If you use macOS, I highly recommend using Homebrew to manage Unix tools in general. With either of the installation methods above you don’t need to install pip
and venv
separately. Debian/Ubuntu packages tend to be more modular, which is nice for containerized applications.
Windows
You can install Python
Download the Windows installer from python.org.
- On the first installer screen, be sure to check the box to update your PATH environment variable.
That’s it. Now you can run python
and pip
in the cmd
shell or Powershell. I recommend installing Windows Terminal: https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701, which is a very nice terminal and allows you to run any shell, in separate tabs if you want, including Linux shells.
Since many Unix/Linux distributions use Python 2 and Python 3 on the same system,
python
runs Python 2 and you must run Python 3 withpython3
. On Windows, you run Python 3 withpython
. Note that if you use the Linux version of Python 3 in WSL you’ll need to run it withpython3
but usepython
when you’re running Python 3 in a Windows shell like thecmd
shell or PowerShell.