Introduction to Python · 3 / 10 Theory

Python installation and configuration

In this article you will learn how to prepare the Python development environment on Windows, macOS or Linux. You only need to install the interpreter and a text editor.

1. Check if Python is already installed

Open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS and Linux) and run:

python --version

On macOS and Linux the command may be python3. If you see something like Python 3.12.4, you already have Python. If the command is not found, or the version starts with 2, install a recent Python 3.

2. Install Python

Windows

  1. Go to python.org/downloads and download the latest installer for Windows.
  2. Run it and check the option "Add python.exe to PATH" on the first screen.
  3. Click "Install Now" and wait until the installation ends.

macOS

Download the installer from python.org/downloads and run it. If you use Homebrew you can also run:

brew install python

Linux

Most distributions include Python. On Debian or Ubuntu you can install everything you need with:

sudo apt update
sudo apt install python3 python3-pip python3-venv

3. Check the installation

Close and reopen the terminal and run again:

python --version
pip --version

pip is the tool that installs third-party libraries. If both commands show a version, the installation is correct.

4. The interactive interpreter

If you run python without arguments you enter the interactive interpreter (REPL), where you can try instructions one by one:

>>> 2 + 3
5
>>> print("Hello")
Hello

Use exit() to leave it.

5. Virtual environments (recommended)

A virtual environment keeps the libraries of each project separated from the others:

python -m venv .venv

To activate it, run .venv\Scripts\activate on Windows or source .venv/bin/activate on macOS and Linux. From that moment, pip install installs the libraries only inside that project.

6. Choose an editor

You can write Python in any text editor, but a code editor makes it easier. In the next article you will find the most popular options.