Install Python
You run every example in this course on your own computer. This page installs the two tools you need: Python and uv.
What you will install
Section titled “What you will install”- 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.
Open a terminal
Section titled “Open a terminal”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.
Check whether Python is already installed
Section titled “Check whether Python is already installed”Many computers already have a Python. Check its version first.
python3 --versionpy --versionpython3 --versionThe 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.
Install Python
Section titled “Install Python”-
Go to python.org/downloads and download the latest macOS installer.
-
Open the downloaded
.pkgfile and follow the steps. -
Close the terminal and open a new one, so that it finds the new Python.
-
Check the version again:
Terminal python3 --version
If you use Homebrew, a package manager for macOS, you can install Python with it instead:
brew install python@3.13-
Go to python.org/downloads and download the latest Windows installer.
-
Run the installer. On the first screen, tick Add python.exe to PATH. PATH is the list of folders where Windows looks for commands. Without this box, the
pythoncommand is not found. -
Click Install Now.
-
Close PowerShell and open a new window, then check the version:
Terminal py --version
You can also install Python with winget, the package manager built into Windows:
winget install Python.Python.3.13Most Linux systems include Python. Check the version with python3 --version. If it is lower than 3.12, the simplest fix is to let uv install a newer Python for you (see the next section). You can also use your system’s package manager.
On Ubuntu 24.04 or newer and Debian 13 or newer:
sudo apt updatesudo apt install python3 python3-venv python3-pipOn Fedora:
sudo dnf install python3Install uv
Section titled “Install uv”uv creates environments and installs packages. It is much faster than the older tools, and it can also download Python for you.
curl -LsSf https://astral.sh/uv/install.sh | shWith Homebrew, you can run brew install uv instead.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"With winget, you can run winget install --id=astral-sh.uv -e instead.
curl -LsSf https://astral.sh/uv/install.sh | shClose the terminal and open a new one. Then check that uv works:
uv --versionThe 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:
uv python install 3.13uv keeps this Python for its own environments. It does not replace the Python of your system.
macOS only: install libomp
Section titled “macOS only: install libomp”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:
brew install libompIf you do not have Homebrew, install it first from brew.sh. Windows and Linux do not need this step.
Check Python from Python
Section titled “Check Python from Python”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).
import sys
print(sys.version_info >= (3, 12))TrueYou 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.
Next step
Section titled “Next step”Your computer now has Python and uv. Next, create a project folder with its own environment: Virtual environments.