Ad – 728Γ—90
🌱 Beginner

How to Install Python – Complete Setup Guide

Before you can write a single line of Python, you need Python installed on your computer. This guide walks you through every step of installing Python 3 on Windows, macOS, and Linux β€” plus how to set up a code editor and verify your installation is working correctly.

⏱️ 15 min read 🎯 Beginner πŸ“… Updated 2026

Which Python Version to Install?

Always install the latest stable Python 3.x release. At the time of writing, that's Python 3.12+. Never install Python 2 β€” it's been retired since January 2020 and is no longer supported.

πŸ’‘
Rule: Always Use Python 3.10 or Newer

Python 3.10 introduced match-case (pattern matching). Python 3.11 made error messages much clearer. Python 3.12 is faster and has better type hints. Any version 3.10+ is excellent for learning.

Installing Python on Windows

Windows doesn't come with Python pre-installed, so you need to download and install it manually. Follow these steps carefully:

  1. Go to the official Python website
    Visit python.org/downloads. The site automatically detects you're on Windows and shows the latest release button.
  2. Download the installer
    Click "Download Python 3.x.x" (the big yellow button). This downloads a .exe installer file.
  3. Run the installer β€” CRITICAL: Check "Add Python to PATH"
    Double-click the downloaded file. At the bottom of the installer, you'll see a checkbox: "Add Python 3.x to PATH". Check this box before clicking Install Now. This step is essential β€” without it, you can't run Python from the command line.
  4. Click "Install Now"
    The installer sets up Python, pip (package manager), and IDLE (Python's built-in editor). The installation takes 1-2 minutes.
  5. Verify the installation
    Open Command Prompt (press Win+R, type cmd, press Enter) and type:
Terminal
python --version
β–Ά Output
Python 3.12.2
⚠️
If "python" opens the Windows Store instead

Some Windows systems have a Python stub that opens the Store. Fix: Search "Manage app execution aliases" in Windows Settings and turn off the Python aliases. Then restart Command Prompt.

Installing Python on macOS

macOS may come with Python 2.7 pre-installed (on older systems), but you need Python 3. There are two recommended approaches:

Option 1: Official Installer (Recommended for Beginners)

  1. Go to python.org/downloads and click the macOS download link.
  2. Download the .pkg installer (choose the macOS 64-bit universal2 installer).
  3. Double-click the .pkg file and follow the installation wizard.
  4. Verify in Terminal (Applications β†’ Utilities β†’ Terminal):
Terminal
python3 --version
# Output: Python 3.12.2
πŸ’‘
On macOS, use python3 not python

On macOS, python may still point to the old Python 2. Always use python3 and pip3 on Mac to ensure you're using Python 3.

Option 2: Homebrew (Recommended for Developers)

Terminal
# Install Homebrew first (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Then install Python
brew install python

# Verify
python3 --version

Installing Python on Linux

Most Linux distributions come with Python 3 pre-installed. Check first:

Terminal
python3 --version

If Python 3 is not installed or you need a newer version:

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

# Fedora/RHEL
sudo dnf install python3 python3-pip

# Arch Linux
sudo pacman -S python python-pip
Ad – 336Γ—280

Understanding pip – Python's Package Manager

Python comes with pip (Pip Installs Packages), a tool to install third-party libraries. You'll use it constantly as a Python developer.

Terminal
# Check pip version
pip --version        # Windows
pip3 --version       # macOS/Linux

# Install a package (example: requests library)
pip install requests

# Install a specific version
pip install requests==2.31.0

# List installed packages
pip list

# Uninstall a package
pip uninstall requests

Choosing a Code Editor (IDE)

You write Python code in a text editor or IDE (Integrated Development Environment). Here are the best options:

EditorBest ForCostDifficulty
VS CodeGeneral purpose, all skill levelsFreeEasy
PyCharm CommunityPython-specific, powerful featuresFreeModerate
IDLEAbsolute beginners, comes with PythonFreeVery Easy
Jupyter NotebookData science, interactive codingFreeEasy
Sublime TextFast, lightweight editingFree/PaidEasy

Setting Up VS Code for Python (Recommended)

  1. Download VS Code from code.visualstudio.com
  2. Open VS Code and press Ctrl+Shift+X (or Cmd+Shift+X on Mac) to open Extensions
  3. Search for "Python" by Microsoft and click Install
  4. Press Ctrl+Shift+P and type "Python: Select Interpreter" to choose your Python installation
  5. Create a new file with a .py extension and start coding!

Testing Your Installation

Let's confirm everything works by running a simple Python script:

Python – test.py
import sys

print("Python is working!")
print(f"Version: {sys.version}")
print(f"Installation: {sys.executable}")

# Quick test
numbers = [1, 2, 3, 4, 5]
print(f"Sum of {numbers} = {sum(numbers)}")

Save this as test.py and run it:

Terminal
python test.py      # Windows
python3 test.py     # macOS/Linux
β–Ά Output
Python is working! Version: 3.12.2 (main, ...) Installation: /usr/bin/python3 Sum of [1, 2, 3, 4, 5] = 15

The Interactive Python Shell (REPL)

Python has an interactive shell where you can type code and see results instantly β€” great for experimenting:

Terminal
python        # Windows
python3       # macOS/Linux
Python REPL
>>> print("Hello!")
Hello!
>>> 2 + 2
4
>>> name = "Alice"
>>> f"Hello, {name}!"
'Hello, Alice!'
>>> exit()   # To quit the REPL

πŸ‹οΈ Practical Exercise

  1. Install Python on your computer following the steps for your operating system.
  2. Open Terminal/Command Prompt and verify with python --version.
  3. Open the interactive shell and compute: 100 * 3.14
  4. Create a hello.py file that prints your name and favorite number, then run it.
  5. Install the requests library using pip.

πŸ”₯ Challenge Exercise

Install VS Code, add the Python extension, and create a project folder. Write a Python script that prints a 5Γ—5 multiplication table. Run it from the VS Code terminal.

Interview Questions on Python Setup

  • What is pip and what is it used for?
  • How do you check which version of Python is installed?
  • What is the difference between Python 2 and Python 3?
  • What does "Add to PATH" mean and why is it important?
  • What is a virtual environment and why should you use one?
  • What is IDLE? What is the difference between IDLE and VS Code?

πŸ“‹ Summary

  • Always install Python 3.10+ β€” never Python 2.
  • On Windows: download from python.org, check "Add to PATH" during install.
  • On macOS: use the official installer or Homebrew; use python3 command.
  • On Linux: use your package manager (apt, dnf, pacman).
  • pip is Python's package manager β€” use it to install third-party libraries.
  • VS Code with the Python extension is the recommended editor for beginners.
  • The Python REPL (python3 in terminal) is great for quick experimentation.

Frequently Asked Questions

Can I have multiple Python versions installed? +

Yes. Tools like pyenv (Mac/Linux) or Python Launcher (Windows) let you manage multiple Python versions. You can specify which version to use per project. Virtual environments (venv) help isolate project dependencies.

Should I use Anaconda instead of standard Python? +

Anaconda is a Python distribution bundled with 250+ data science packages. It's ideal if you're doing data science from day one. For general Python learning, start with the official Python distribution β€” it's lighter and teaches you to manage packages yourself.

What is a virtual environment? Do I need one right now? +

A virtual environment isolates project dependencies so different projects don't conflict. You don't need one immediately as a beginner, but it's good practice to use them for any real project. We cover this in the Virtual Environments lesson.