Skip to content

Install Python

You run every example in this course on your own computer. This page installs the two tools you need: Python and uv.

  • Python is the programming language of this course. The interpreter is the program that reads your Python code and runs it. When people say “install Python”, they mean “install the interpreter”.
  • uv is a fast tool that creates project environments and installs Python packages. A package is code that other people wrote and published, for example pandas. The next page uses uv.

The course needs Python 3.12 or newer. All the output on this site comes from Python 3.13. Python 3.12 and 3.14 also work.

A terminal is a window where you type commands as text instead of clicking buttons. You use it to install tools and to run your scripts.

System How to open a terminal
macOS Press Cmd + Space, type Terminal, press Enter.
Windows Press the Windows key, type PowerShell, press Enter.
Linux Press Ctrl + Alt + T, or open “Terminal” from the app menu.

In this course, a code block titled Terminal holds commands for the terminal. Type or paste one line at a time and press Enter. These are not Python code.

Many computers already have a Python. Check its version first.

Terminal
python3 --version

The command prints one line with the version number, such as Python 3.13.7. Look at the second number. If it is 12 or higher, you can skip to Install uv. If the command fails or the version is lower, install Python as shown below.

  1. Go to python.org/downloads and download the latest macOS installer.

  2. Open the downloaded .pkg file and follow the steps.

  3. Close the terminal and open a new one, so that it finds the new Python.

  4. Check the version again:

    Terminal
    python3 --version

If you use Homebrew, a package manager for macOS, you can install Python with it instead:

Terminal
brew install python@3.13

uv creates environments and installs packages. It is much faster than the older tools, and it can also download Python for you.

Terminal
curl -LsSf https://astral.sh/uv/install.sh | sh

With Homebrew, you can run brew install uv instead.

Close the terminal and open a new one. Then check that uv works:

Terminal
uv --version

The command prints uv and a version number. If the terminal says the command is not found, open a new terminal window and try again.

If your system Python is older than 3.12, let uv install a current Python:

Terminal
uv python install 3.13

uv keeps this Python for its own environments. It does not replace the Python of your system.

XGBoost and LightGBM are two machine learning libraries in Part 5. On macOS they need libomp, a small system library that lets a program use several processor cores at once. Install it with Homebrew:

Terminal
brew install libomp

If you do not have Homebrew, install it first from brew.sh. Windows and Linux do not need this step.

The commands above asked the terminal for the version. You can also ask Python itself. The module sys holds facts about the running interpreter. sys.version_info is its version as numbers, and Python can compare it with (3, 12).

check_python.py
import sys
print(sys.version_info >= (3, 12))
Output
True

You will run this check yourself after the next two pages, once you have a project folder and an editor. True means your Python is new enough.

Your computer now has Python and uv. Next, create a project folder with its own environment: Virtual environments.