Python course menu
How to Install Python on Windows, macOS and Linux (Step by Step)
Install Python 3 correctly on Windows, macOS or Linux, check that it works, run code in the interactive shell and from a .py file, and set up a beginner-friendly code editor.
On this page
Before writing Python on your own computer, you need two things: the Python interpreter (the program that runs Python code) and a code editor to write it in. This lesson walks through both, on every major operating system.
Which version?#
Install the latest Python 3 release from python.org. Python 2 reached its end of life in 2020 and should not be used for anything new. Everything in this course works on Python 3.10 and newer.
Windows#
- Go to python.org/downloads and click the yellow Download Python 3.x button.
- Run the downloaded installer.
- Tick "Add python.exe to PATH" at the bottom of the first screen. This is the step most people miss.
- Click Install Now and wait for it to finish.
macOS#
macOS may include an old system Python that you should not modify. Install your own:
- Download the macOS installer from python.org/downloads and run it, or
- If you use Homebrew:
brew install python.
On macOS, the command is usually python3 rather than python.
Linux#
Most Linux distributions already include Python 3. Check first (below). If you need to install it:
# Ubuntu / Debian
sudo apt update
sudo apt install python3 python3-pip python3-venv
# Fedora
sudo dnf install python3Check that it worked#
Open a terminal (on Windows: Command Prompt or PowerShell; on macOS: Terminal) and run:
python --versionPython 3.13.9Your version number may be newer. If python does not work on macOS or Linux, try python3 --version.
The interactive shell#
Type python (or python3) and press Enter. You will see the >>> prompt: Python is waiting for a line of code.
>>> 2 + 3
5
>>> print("Hello!")
Hello!
>>> exit()The shell (also called the REPL: read, evaluate, print, loop) is perfect for quick experiments. Anything you type is run immediately. Type exit() or press Ctrl+D (Ctrl+Z then Enter on Windows) to leave.
Running a .py file#
For real programs, write code in a file:
- Create a folder, for example
python-practice. - Inside it, create a file called
hello.pycontaining:
print("Hello from a file!")- In the terminal, go to that folder and run it:
cd python-practice
python hello.pyHello from a file!Choosing a code editor#
Any text editor works, but a code editor highlights your code, spots mistakes, and runs programs with one click. Good free choices:
pip: installing extra packages#
Python comes with pip, a tool for installing packages other people have written. Check it:
python -m pip --versionYou will use it later, for example python -m pip install requests. Using python -m pip (instead of just pip) makes sure the package is installed for the same Python you run.
Common mistakes#
Practice#
Practice exercise
- Install Python and confirm
python --version(orpython3 --version) prints a version starting with3. - Open the interactive shell and calculate
365 * 24. - Create
first.pythat prints your name, and run it from the terminal.
Show solution
- You should see something like
Python 3.13.9. - In the shell:
>>> 365 * 24
8760first.py:
print("Asha")Run with python first.py. If you see your name, your setup is complete.
Key takeaway#
Next: write your first Python program.
Finished this lesson?