Checking and Installing Python

Check whether a suitable Python interpreter is already available on macOS, Windows, or Linux. If it is missing or too old, follow a trusted installation path and verify the result before running a local script.

Python is a programming language. To run Python code on your own computer, you also need a Python interpreter. The interpreter is the software that reads the code and carries out its instructions.

Your computer may already have a Python interpreter. We will check before installing anything. If Python is missing, this lesson shows where to get it safely.

All examples in the first chapters also run in the browser. You can continue with those examples and return to local setup when you need it.

Open a Terminal

A terminal is an application where you type commands and read their output. The application has a different name on each operating system:

  • macOS: open Terminal from Applications → Utilities, or search for it with Spotlight.
  • Windows: open the Start menu, search for PowerShell, and open it.
  • Linux: open your distribution's terminal application. It is often named Terminal.

A terminal command is not Python code. It is an instruction to your operating system. In this lesson, the commands ask whether a Python interpreter is available.

Check for Python 3

On macOS or Linux, type:

python3 --version

On Windows PowerShell, type:

python --version

Then press Enter. A working command prints a version:

Python 3.14.6

Your exact version number may differ. This book supports Python 3.11 through 3.14. Python 3.11 is the oldest version in that range and is still found on some systems; 3.12, 3.13, and 3.14 also work. A newer stable Python 3 release should work as support becomes available, but avoid preview releases for now. The examples do not depend on one exact minor version within this range.

The first number is the major version. The second is the minor version. In Python 3.14.6, the major version is 3 and the minor version is 14.

Interpret the Result

The command will lead to one of three useful outcomes.

  1. Python 3.11 or newer appears. A suitable interpreter is available. Keep using the command that worked.
  2. An older Python version appears. Python exists, but it is too old for this book. Install a current stable Python 3 release.
  3. The command is not found. The terminal cannot find Python under that command name. Try the alternative below, then install Python if needed.

On Windows, py may also be available:

py --version

If python does not work but py prints a suitable Python 3 version, you can use py in later commands. For example:

py hello.py

On macOS or Linux, some systems provide python as well as python3. We use python3 because it makes the intended major version explicit.

When the Command Is Missing

A missing command is a setup result, not an error in Python code. On macOS or Linux, the terminal may report something similar to:

command not found: python3

PowerShell may report that python is not recognized as a command. The wording can vary, but the meaning is the same: the terminal did not find an interpreter under that name.

On Windows, try both checks before installing:

python --version
py --version

If neither command prints Python 3.11 or newer, follow the installation path for your operating system.

Install from a Trusted Source

Installation screens and package names change over time. Use an official source instead of copying commands from an unknown page.

Windows

Open python.org/downloads and install the current stable Python release for Windows. The official Windows installation uses the Python Install Manager.

After installation, close PowerShell, open it again, and run:

python --version

If needed, also try:

py --version

macOS

Open Python releases for macOS and choose the installer for the current stable release. Do not choose a preview, alpha, beta, or release-candidate build.

After installation, close Terminal, open it again, and run:

python3 --version

Linux

Python is often installed because the operating system uses it. If python3 --version is missing or too old, follow the Python package instructions for your Linux distribution.

Do not remove or replace the operating system's Python installation. Install the supported package alongside it when your distribution recommends that approach.

If Python Is Installed but the Command Still Fails

Sometimes installation succeeds but the terminal still cannot find the command. Closing and reopening the terminal fixes many cases because the new terminal reloads the system settings.

The terminal uses a setting named PATH to decide where to look for commands. An installer may fail to add Python to that list, or an older Python command may appear earlier in it. Do not change PATH at random. Its format and safe values depend on the operating system and the way Python was installed.

If reopening the terminal does not help:

  1. copy the exact error message, but remove any personal folder names or other private information;
  2. note your operating system, how you installed Python, and the command you entered;
  3. search for the error together with those details;
  4. prefer Python's official documentation and your operating system's documentation;
  5. read what a suggested command changes before running it, especially if it requests administrator access.

For Windows command and PATH problems, begin with Python's Windows troubleshooting guide. For macOS or Linux, include the operating-system or distribution name in the search because the correct setup differs between systems.

Verify the Installation

After installing Python:

  1. close and reopen the terminal;
  2. run the version command for your operating system;
  3. confirm that it prints Python 3.11 or newer;
  4. remember which command worked: python3, python, or py.

Later lessons will use that command to run files. For example, macOS and Linux commonly use:

python3 hello.py

Windows commonly uses:

python hello.py

or:

py hello.py

All three forms can run the same hello.py file. Only the command used to start the interpreter differs.

You do not need to install NumPy, Matplotlib, an editor, or any other package yet. We will add each tool when a lesson needs it.

Exercise: Recognize a suitable Python version

Which output shows a version suitable for this book?

Version output

Select one choice, then check.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintCompare the major and minor versions

First check that the major version is 3. Then compare the minor version with 11.

SolutionChoose Python 3.13

Python 3.13.14 is suitable. Its major-and-minor version pair is 3.13, which is newer than 3.11.

Python 2 is a different major version. Python 3.8 is Python 3, but it is older than the version used by this book.

Exercise: Choose the next setup step

A Windows reader runs python --version, but PowerShell cannot find the command. What is the best next step?

Next step

Select one choice, then check.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintThe terminal has not run any Python code

A missing terminal command does not tell us that the Python code is wrong. Windows may provide the interpreter through another command.

SolutionTry the alternative Windows command

Run:

py --version

If it prints Python 3.11 or newer, use py. If neither python nor py works, install a current stable release from Python's official download page.

What You Need for the Next Lesson

Local setup is complete when one command—python3, python, or py—prints a suitable version. Keep that command available. The next lesson creates a plain-text .py file and uses the command to run it.

References

Review

Not marked done.