📚 Reference guide

Install Python 3 and Run Your First Script

Check whether Python 3 is already installed, install it from official sources if it is not, and run a short script that prints the version.

Series: Python for small scripts

Based on the official Python documentation. Date checked: November 27, 2026. Script tested on Python 3.13.5.

Series: Python for small scripts, Part 1 of 10. Previous: none (this is Part 1). Next: Part 2: Variables, Types, and print.

TL;DR

Before you start

The finished script

Save this as hello.py in that folder:

import sys

print("Hello from Python.")
print("Version:", sys.version)

When you run it, you should see two lines. Your version text will differ:

Hello from Python.
Version: 3.13.5 (main, Aug 10 2026, 12:06:59) [GCC 14.2.0]

Steps

  1. See whether Python 3 is already there. Open a new terminal and run python3 --version. If that fails, try python --version. Why: many Linux and macOS systems already have a python3 command. If it prints 3.11 or newer, skip the install. You should see: a line like Python 3.13.5.
  2. Install only if the check failed, or if the version is 3.10 or older. Then close the terminal, open a new one, and repeat the check. Why: a new terminal picks up the updated command path. You should see: Python 3.11 or newer.
    • Windows: Install the Python install manager from python.org/downloads or the Microsoft Store, then open a new terminal and run python. If no runtime is installed yet, that command installs the current latest release. You can also run py install default.
    • macOS: Download the current .pkg installer from python.org, run it, then double-click Install Certificates.command in /Applications/Python 3.15/ (the folder name follows the version you installed). Use python3. Do not delete Apple’s /usr/bin/python3.
    • Linux: Python is already installed on most distributions. If the version check passed, you are done. If not, use your distribution’s package manager (see the official Unix guide).
  3. Create the folder and the file. Make a folder named python-scripts and save the script above as hello.py. Why: a dedicated folder keeps practice files together. You should see: hello.py in that folder.
  4. Run the script. Change into python-scripts and run python3 hello.py. On Windows, use python hello.py. Why: this asks the interpreter to read the file and run it. You should see: the two-line output shown above, with your version on the second line.

If it fails

Stay safe

Next

Part 2: Variables, Types, and print

Sources

Spot something wrong or outdated? Leave a comment below. Every comment is reviewed to keep these posts accurate.

By commenting, you agree to our Terms of use and confirm this is your own work. Short quotes are fine with a credit and link. Copied, unsafe, or abusive comments are removed. See something copied? Say so here.