Set Up Python: Install & Your First Program

Install Python on Windows, macOS or Linux, configure VS Code, and run hello.py.

Step 1: Download Python

Download the latest version of Python from the official website.

  1. Select the version for your OS (Windows, macOS, or Linux).
  2. Choose the recommended installer.
  3. Download the installer.

Step 2: Run the Installer

Run the downloaded installer. The steps are slightly different for each OS:

Windows

  1. Double-click the .exe file.
  2. Important: check “Add Python to PATH”.
  3. Click Install Now (or Customize installation for advanced options).

macOS

  1. Double-click the .pkg file.
  2. Follow the on-screen instructions.

Linux

Python may already be installed. Check with:

python3 --version

If not installed, use your package manager:

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

# Fedora/CentOS/RHEL
sudo dnf install python3 python3-pip

# Arch Linux
sudo pacman -S python python-pip
Note: On Linux and macOS, prefer python3 and pip3 to ensure Python 3 is used.

Step 3: Verify Installation

Open a terminal and check versions:

python --version   # or: python3 --version
pip --version      # or: pip3 --version

Step 4: Choose a Code Editor/IDE

Beginner-friendly options:

  • Visual Studio Code (recommended): Download
  • Thonny: Download
  • PyCharm Community Edition: Download
  • IDLE: Ships with Python.

Set up VS Code for Python

  1. Install the official Python extension by Microsoft.
  2. Install Pylance for intelligent code completion and type checking.

Step 5: Write Your First Program

Create a file named hello.py and add:

print("Hello, World!")

Save, open a terminal, navigate to the file, and run:

python hello.py   # or: python3 hello.py

You should see Hello, World! in the output. 🎉