Before you can write and run Python code, you need Python installed on your computer along with a place to write it. This guide walks through installing Python on Windows, macOS, and Linux, confirming the install worked, and running your very first script.
Installing Python on Windows
Download the latest installer from the official python.org/downloads page and run it. On the first installer screen, make sure you check the box labeled "Add python.exe to PATH" before clicking Install — this lets you run Python from any terminal window without extra configuration.
Installing Python on macOS and Linux
macOS and most Linux distributions come with some version of Python pre-installed, but it's often an older version used internally by the OS, so it's best to install a fresh copy. On macOS, the easiest route is Homebrew:
brew install python3
On Debian/Ubuntu-based Linux distributions, use the built-in package manager:
sudo apt update
sudo apt install python3 python3-pip
Verifying the Installation
Once installed, open a terminal (Command Prompt, PowerShell, or Terminal) and check the version:
python --version
# or, on some systems:
python3 --version
Output:
Python 3.12.4
If you see a version number instead of an error like "command not found," Python is installed correctly. Some systems use python3 as the command instead of python — if one doesn't work, try the other.
Running Your First Script
Create a new file named hello.py in a text editor and add one line:
print("Python is set up correctly!")
Then run it from the terminal, in the same folder as the file:
python hello.py
Output:
Python is set up correctly!
Choosing a Code Editor
You can write Python in any plain text editor, but a dedicated code editor makes life much easier. Visual Studio Code (free) with its official Python extension is the most common choice today, offering autocomplete, error highlighting, and a built-in terminal. PyCharm is another popular, more Python-specific option.
As your projects grow, you'll also want to isolate each project's dependencies — that's what virtual environments are for, a topic covered in detail once you're comfortable with the basics. For now, you're ready to start learning the language itself, beginning with Python's syntax and indentation rules.
