Lesson 2 of 26 in Python for Beginners · 15m

Installing Python 3 on Windows, macOS and Linux

Before you can run Python code you need the Python interpreter on your computer. Installing it takes about ten minutes. The steps differ a little between operating systems, so follow the tab for yours and skip the others.

You will also meet the terminal in this lesson. A terminal (also called a command line, shell, Command Prompt or PowerShell) is a window where you type commands as text instead of clicking. Programmers use it all the time, and you only need a handful of commands for this course.

Which version?

Install the latest stable version of Python 3 listed on python.org. This course needs Python 3.12 or newer; anything newer than that is fine. Versions are numbered like 3.12.7: the 3 is the major version, 12 is the feature release, and 7 is a bug-fix release. Programs written for 3.12 run on 3.13 and 3.14 as well, with very rare exceptions.

Avoid "pre-release", "alpha", "beta" or "release candidate" downloads. They are test versions for developers.

Windows

  1. Go to python.org, open Downloads and choose Windows. Download the recommended installer for the latest Python 3 release.
  2. Run the installer. If it offers a checkbox called Add python.exe to PATH, tick it. This lets the terminal find Python.
  3. Finish the installation, then open PowerShell or Command Prompt from the Start menu.
  4. Type py --version and press Enter. You should see something like Python 3.13.1. If py is not recognised, try python --version.

On Windows the command to start Python is usually py (the Python launcher) or python. Wherever this course writes python3, use py instead.

You can also install Python from the Microsoft Store. That works for this course too, but stick to one method so you do not end up with two copies.

macOS

  1. Go to python.org, open Downloads and choose macOS. Download the installer for the latest Python 3 release and run it.
  2. Open the Terminal app (press Cmd+Space, type "Terminal", press Enter).
  3. Type python3 --version and press Enter. You should see something like Python 3.13.1.

Use python3, not python, on a Mac. Recent versions of macOS include a python3 command that may offer to install Apple's command line developer tools, which bring an older Python with them. Installing from python.org gives you a current version.

If you already use the Homebrew package manager, brew install python is a good alternative.

Linux

Most Linux distributions already include Python 3. Open a terminal and type python3 --version.

If it is older than 3.12, or missing, install a newer one with your package manager. On Debian or Ubuntu, for example:

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

Older releases of a distribution may not offer 3.12 or newer in their default packages; in that case upgrade the distribution or use a tool such as pyenv. Do not remove or replace the system Python, because parts of the operating system depend on it.

Check that it works

Whatever your system, finish by checking the version from a terminal. On macOS and Linux:

python3 --version

On Windows:

py --version

Either command prints one line such as Python 3.12.8 or Python 3.14.0. The exact number does not matter as long as it starts with 3. and the second number is 12 or higher.

  1. Download Get the latest stable Python 3 installer from python.org (or use your package manager on Linux).
  2. Install Run the installer. On Windows, tick "Add python.exe to PATH" if you see it.
  3. Open a terminal PowerShell on Windows, Terminal on macOS, any terminal on Linux. Open a new one after installing.
  4. Check the version Run py --version (Windows) or python3 --version (macOS, Linux) and confirm it says 3.12 or newer.
  5. Make a course folder Create a folder such as python-course in your Documents to keep everything you write.

What you just installed

The installer put several things on your computer, and it helps to know their names because you will meet them again:

  • The interpreter, the program called python3, python or py, which runs your code.

  • The standard library, hundreds of ready-made modules for maths, dates, files, random numbers and more. You will use several of them in section 6.

  • pip, the tool that downloads and installs extra packages written by other people. It also gets its own lesson in section 6.

  • IDLE, a simple editor and shell that comes with the python.org installers for Windows and macOS.

None of these cost anything, and none of them send your code anywhere. Everything runs on your own computer, so you can experiment freely without breaking anything important. The worst that can happen is that one of your own files gets changed, which is another reason to keep your course work in its own folder.

When it does not work

Installation problems are frustrating, but they are nearly always one of a few things:

  • "command not found" or "is not recognized as an internal or external command". The terminal cannot find Python. Close the terminal and open a new one, because terminals only pick up new programs when they start. On Windows, try py instead of python, or run the installer again and tick the PATH option.

  • The wrong version starts. You may have several copies of Python. On macOS and Linux, use python3, or name the version directly, as in python3.13. On Windows, py -0 lists the versions the launcher knows about.

  • Typing python on Windows opens the Microsoft Store. Windows has a shortcut that does this when Python is not installed or not on the PATH. Use py, or install Python and open a new terminal.

  • You typed the command inside Python by mistake. If you see the >>> prompt, you are already inside Python. Type exit() and press Enter to get back to the terminal first. The next lesson explains this prompt.

A few terminal commands

You only need three terminal commands to follow this course. cd changes the current folder, ls (macOS, Linux and PowerShell) or dir (Command Prompt) lists the files in it, and python3 file.py (or py file.py on Windows) runs a Python file. For example:

cd Documents/python-course
ls
python3 hello.py

The terminal always has a current folder. When you run python3 hello.py, Python looks for hello.py in that folder, so if you get "No such file or directory", the usual fix is to cd into the folder that contains the file.

Key takeaways

  • Install the latest stable Python 3 from python.org (or your Linux package manager); this course needs 3.12 or newer.
  • On Windows start Python with py; on macOS and Linux use python3.
  • Check the installation with py --version or python3 --version in a newly opened terminal.
  • Most problems come from an old terminal window, the PATH setting, or several Python versions installed side by side.
Sources
  • Python downloads
  • Python documentation: Using Python on Windows
  • Python documentation: Using Python on macOS
  • Python documentation: Using Python on Unix platforms

This lesson also has interactive exercises. Open the course to try them and track your progress.

Keep going with Python for Beginners

This is one of 26 lessons in the course. Enroll to get the rest of the course, with an AI tutor that knows the material, flashcards and a certificate when you finish.

Enroll for free

More free lessons from this course