Skip to main content
This guide will help you get CPython installed and running in just a few minutes. Whether you prefer downloading pre-built binaries or building from source, we’ll walk you through the fastest path to writing your first Python program.

Choose Your Installation Method

Download Binary

Fastest way to get started. Pre-built installers available for all major platforms.

Build from Source

Full control over features and optimizations. Recommended for development and customization.

Option 1: Install Pre-Built Binary

On Windows

1

Download Python

Visit python.org/downloads and download the latest Windows installer
2

Run Installer

Double-click the installer and check “Add Python to PATH”
3

Verify Installation

Open Command Prompt and run:
python --version
You can also install Python from the Microsoft Store for easier updates and management.

On macOS

1

Download Python

Download the macOS installer from python.org/downloads
2

Install Package

Open the downloaded .pkg file and follow the installation wizard
3

Verify Installation

Open Terminal and run:
python3 --version
Alternatively, use Homebrew: brew install python3

On Linux

Most Linux distributions include Python. To install or update:
sudo apt update
sudo apt install python3 python3-pip

Option 2: Build from Source

Building from source gives you the latest features and allows custom optimizations.

Quick Build (Unix/Linux/macOS)

1

Download Source

git clone https://github.com/python/cpython.git
cd cpython
2

Configure

./configure
3

Build

make -j$(nproc)
4

Test

make test
5

Install

sudo make install
This installs Python as python3. Use make altinstall to avoid overwriting your system Python.

Quick Build (Windows)

1

Install Visual Studio

Install Visual Studio 2017 or later with Python workload
2

Download Source

Clone the repository or download from python.org/downloads/source
3

Build

Open Command Prompt in the PCbuild directory:
build.bat
4

Test

rt.bat -q

Your First Python Program

Now that Python is installed, let’s write your first program!

Interactive Mode

Launch the Python interpreter:
python3
You’ll see the Python prompt:
Python 3.15.0 (default, Mar 4 2026, 10:30:00)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Try some Python code:
>>> print("Hello, CPython!")
Hello, CPython!

>>> 2 + 2
4

>>> import sys
>>> sys.version
'3.15.0 (default, Mar 4 2026, 10:30:00) \n[GCC 11.2.0]'

>>> # Exit with Ctrl+D (Unix) or Ctrl+Z (Windows)
Use quit() or exit() to leave the interactive interpreter.

Script Mode

Create a file named hello.py:
hello.py
#!/usr/bin/env python3
"""My first CPython program"""

def greet(name):
    """Greet someone by name"""
    return f"Hello, {name}!"

if __name__ == "__main__":
    message = greet("World")
    print(message)
    
    # Try some basic operations
    numbers = [1, 2, 3, 4, 5]
    total = sum(numbers)
    print(f"Sum of {numbers} = {total}")
Run your script:
python3 hello.py
Output:
Hello, World!
Sum of [1, 2, 3, 4, 5] = 15

Using Modules

Python’s standard library provides powerful modules:
example.py
import os
import json
from pathlib import Path
from datetime import datetime

# Working with files
current_dir = Path.cwd()
print(f"Current directory: {current_dir}")

# JSON data
data = {
    "name": "CPython",
    "version": "3.15",
    "timestamp": datetime.now().isoformat()
}
print(json.dumps(data, indent=2))

# List directory contents
files = os.listdir('.')
print(f"Found {len(files)} files")

Essential Commands

Here are the most common Python commands you’ll use:
python3 script.py

Virtual Environments

For project isolation, use virtual environments:
1

Create Virtual Environment

python3 -m venv myproject
2

Activate

source myproject/bin/activate
3

Install Packages

pip install requests numpy pandas
4

Deactivate

deactivate
Virtual environments keep your project dependencies isolated and prevent version conflicts.

Package Management with pip

CPython includes pip, the Python package installer:
# Install a package
pip install requests

# Install specific version
pip install requests==2.28.0

# Upgrade a package
pip install --upgrade requests

# List installed packages
pip list

# Show package info
pip show requests

# Uninstall package
pip uninstall requests

# Save dependencies
pip freeze > requirements.txt

# Install from requirements
pip install -r requirements.txt

Troubleshooting

Command Not Found

If python3 or python is not found:
Add Python to your PATH in ~/.bashrc or ~/.zshrc:
export PATH="/usr/local/bin:$PATH"
Then reload: source ~/.bashrc
The installer should add Python to PATH. If not:
  1. Search for “Environment Variables” in Windows
  2. Edit the PATH variable
  3. Add Python installation directory (e.g., C:\Python315)

Permission Denied

On Unix systems, use sudo make install or install to a user directory:
./configure --prefix=$HOME/.local
make
make install

Import Errors

If modules can’t be imported, check your Python path:
import sys
print(sys.path)

Next Steps

Installation Guide

Detailed installation instructions for all platforms and build options

Python Tutorial

Official Python tutorial covering language features

Standard Library

Explore Python’s comprehensive standard library

Contributing

Learn how to contribute to CPython development
Always use virtual environments for your projects to avoid dependency conflicts!

Quick Reference

Common Python interpreter options:
OptionDescription
-c cmdExecute Python command
-m modRun library module as script
-iEnter interactive mode after running script
-vVerbose output (trace imports)
-OOptimize bytecode
-BDon’t write .pyc files
-uUnbuffered output
That’s it! You’re now ready to start developing with CPython. Happy coding!

Build docs developers (and LLMs) love