Skip to content
C Codeloom
Python

Install Python and Run Your First Program

A step-by-step setup guide for Python 3 on Windows, macOS, and Linux. Install the interpreter, set up VS Code, and write a working Python program in under ten minutes.

·7 min read · By Yash Kesharwani
Beginner 10 min read

What you'll learn

  • How to install Python 3 cleanly on Windows, macOS, or Linux
  • How to set up Visual Studio Code as a Python editor
  • How to write, save, and run your first Python program
  • How to use the interactive Python REPL for quick experiments

Prerequisites

  • A computer running Windows, macOS, or Linux
  • Roughly 10 minutes and an internet connection
  • Optional: read What is Python? first

In the previous post we covered what Python is and why it has become the dominant general-purpose language. This guide is hands-on: by the end you will have a working Python installation, a properly configured editor, and a program you wrote yourself.

Pick the section that matches your operating system, install Python, then continue from “Install a code editor.”

Step 1: Install Python

Important. Always install Python 3. Python 2 was officially retired in 2020 and is no longer maintained. Any tutorial that references python2 is out of date.

On Windows

  1. Open your browser and visit python.org/downloads.
  2. Click the yellow Download Python 3.x.x button to download the installer (.exe).
  3. Run the installer. On the first screen, tick the checkbox labelled “Add python.exe to PATH” at the bottom. This step is critical — without it, the python command will not be available in your terminal.
  4. Click Install Now and wait for completion.

To confirm the installation, open the Start Menu, type cmd, and press Enter. In the terminal window, run:

python --version

You should see output similar to Python 3.13.1. If you do, Python is installed correctly.

On macOS

macOS ships with an outdated, system-only Python that should not be used for development. Install a clean version instead.

The cleanest approach is Homebrew, the standard package manager for macOS. Open Terminal (Cmd+Space → “Terminal”) and run:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once Homebrew is installed, install Python:

brew install python

Verify the installation:

python3 --version

You should see Python 3.13.1 or similar.

If you prefer not to use Homebrew, you can download a graphical installer from python.org/downloads. The end result is the same.

On Linux

Most Linux distributions ship with Python 3 already installed. Check with:

python3 --version

If you get a version number, you are ready. If not, install it using your distribution’s package manager:

# Ubuntu / Debian
sudo apt update && sudo apt install python3 python3-pip

# Fedora
sudo dnf install python3 python3-pip

# Arch Linux
sudo pacman -S python python-pip

Step 2: Install a code editor

Python files are plain text and can technically be written in any text editor. In practice, a dedicated code editor saves significant time through syntax highlighting, autocomplete, integrated error checking, and a built-in terminal — all of which we will use throughout this series.

We will use Visual Studio Code, the most widely adopted editor in the industry. It is free, cross-platform, and maintained by Microsoft.

  1. Visit code.visualstudio.com and download the installer for your operating system.
  2. Run the installer, accepting the default options.
  3. Open VS Code.
  4. In the left sidebar, click the Extensions icon (four squares).
  5. Search for Python and install the extension published by Microsoft. This adds full Python language support — linting, debugging, and IntelliSense — to the editor.

Your environment is now ready.

Step 3: Write your first Python program

  1. Create a new folder somewhere convenient, for example Documents/python-practice.
  2. In VS Code, choose File → Open Folder and select your new folder.
  3. In the file explorer panel on the left, click the New File icon and name the file hello.py. The .py extension tells the operating system and your editor that this is a Python source file.
  4. Type the following line into the file:
print("Hello, world!")
  1. Save the file with Ctrl+S (Cmd+S on macOS).

Three things are worth noticing about that single line:

  • print is a built-in function — a piece of pre-written code that performs a specific job, in this case displaying text on the screen.
  • The parentheses (...) after the name are how you call a function — that is, instruct Python to run it.
  • The double quotes "..." mark the contents as a string, which is the programmer’s term for a piece of text.

Step 4: Run your program

In VS Code, open the integrated terminal: View → Terminal, or press Ctrl+`. A small panel will open at the bottom containing a command prompt. Run:

python hello.py

On macOS and Linux, use python3 instead — the 3 is required, since python on those systems may refer to an older version.

Press Enter. You should see:

Hello, world!

That is a working Python program. Every Python developer on Earth, regardless of where they work today, began at this exact step.

Try it yourself. Modify the message inside the quotes and run the program again. Try printing your own name, today’s date, or any sentence you like. Remember to save the file (Ctrl+S) before running it — Python executes what is on disk, not what is on screen.

Step 5: Use the REPL for quick experiments

Python provides a second mode of operation that is ideal for experimenting with small pieces of code: the REPL, short for Read–Eval–Print Loop. It runs Python one line at a time and shows the result immediately, without needing to save a file.

In your terminal, run python (or python3) with no arguments. You will see three arrows: >>>. This is the interactive prompt. Try the examples below one line at a time:

>>> print("Hello!")
Hello!
>>> 2 + 2
4
>>> "Python" * 3
'PythonPythonPython'
>>> name = "Yash"
>>> print("Hello, " + name)
Hello, Yash

The REPL is the fastest way to test ideas as you learn — much faster than creating a new file for every experiment. To exit, type exit() and press Enter.

Try it yourself. In the REPL, calculate the number of seconds in a year (60 * 60 * 24 * 365), store your name in a variable, and print a greeting that includes it. These are the same building blocks of every Python program you will ever write — get comfortable with them now.

Common installation problems

A few errors are extremely common at this stage. The fixes are quick.

'python' is not recognized as an internal or external command (Windows) The “Add python.exe to PATH” checkbox was not selected during installation. Re-run the Python installer, choose Modify, and tick the box this time.

command not found: python (macOS or Linux) On these systems the executable is named python3, not python. Use the longer name, or create an alias in your shell profile if you prefer.

SyntaxError: EOL while scanning string literal You forgot to close a quotation mark. Make sure each " has a matching ".

No output appears when running the file Make sure the file is saved. In VS Code, unsaved files show a small dot next to the filename in the tab bar — press Ctrl+S until the dot disappears.

Recap

You now have:

  • A working Python 3 installation
  • VS Code configured with the Python extension
  • A complete Python script you wrote and executed
  • Practical familiarity with the REPL for quick experiments

This is a full Python development setup. Every concept in the rest of this series — variables, types, functions, classes, web servers, machine learning models — builds on the foundation you have just put in place.

Next steps

The next post explores Python’s syntax and indentation rules: how Python knows where one block of code ends and another begins, the role of whitespace, and the three most common syntax errors beginners encounter.

→ Next: Python Syntax and Indentation Explained

Encountered a problem during setup? Email codeloomdevv@gmail.com — include a screenshot of the error and I’ll help you get unblocked.