Skip to content
Laviyx Learn

Try

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.

Beginner5 min readUpdated
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#

  1. Go to python.org/downloads and click the yellow Download Python 3.x button.
  2. Run the downloaded installer.
  3. Tick "Add python.exe to PATH" at the bottom of the first screen. This is the step most people miss.
  4. 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:

  1. Download the macOS installer from python.org/downloads and run it, or
  2. 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:

Terminal
# Ubuntu / Debian
sudo apt update
sudo apt install python3 python3-pip python3-venv

# Fedora
sudo dnf install python3

Check that it worked#

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

Terminal
python --version
Output
Python 3.13.9

Your 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.

Python
>>> 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:

  1. Create a folder, for example python-practice.
  2. Inside it, create a file called hello.py containing:
hello.py (Python)
print("Hello from a file!")
  1. In the terminal, go to that folder and run it:
Terminal
cd python-practice
python hello.py
Output
Hello 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:

EditorWhy beginners like it
VS CodeFree, popular, excellent Python extension (install "Python" by Microsoft)
PyCharm CommunityDesigned specifically for Python; lots of help built in
ThonnyVery simple, made for learners; includes its own Python

pip: installing extra packages#

Python comes with pip, a tool for installing packages other people have written. Check it:

Terminal
python -m pip --version

You 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

  1. Install Python and confirm python --version (or python3 --version) prints a version starting with 3.
  2. Open the interactive shell and calculate 365 * 24.
  3. Create first.py that prints your name, and run it from the terminal.
Show solution
  1. You should see something like Python 3.13.9.
  2. In the shell:
Python
>>> 365 * 24
8760
  1. first.py:
Python
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?