Skip to main content
This comprehensive guide covers installing CPython from pre-built binaries or building from source on all supported platforms. Whether you’re setting up a development environment or deploying to production, this guide has you covered.

Installation Options

Unix/Linux

Build from source with configure and make

macOS

Download installer or build with Xcode

Windows

Visual Studio build or pre-built installer

Building from Source (Unix/Linux/macOS)

Building CPython from source gives you full control over features and optimizations.

Prerequisites

For detailed platform-specific dependencies, see the Developer’s Guide.

Standard Build

1

Get the Source

Download from GitHub or python.org:
2

Configure

Run the configure script:
This will detect your system and set up the build environment.
3

Build

Compile CPython:
The -j flag enables parallel compilation for faster builds.
4

Test

Run the test suite to verify the build:
Some tests may be skipped due to missing optional dependencies. This is normal.
5

Install

Install Python system-wide:
This installs Python as python3.

Build Configuration Options

The configure script accepts many options to customize your build:
Run ./configure --help to see all available options.

Optimized Build (PGO + LTO)

For maximum performance, use Profile-Guided Optimization (PGO) and Link-Time Optimization (LTO):
PGO builds take significantly longer (2-3x) because the build process:
  1. Builds an instrumented version
  2. Runs training workload
  3. Rebuilds with optimization data
The optimized build process:
1

Initial Build

Builds an instrumented interpreter with profiling code embedded
2

Profile Collection

Runs benchmark suite to collect execution profile data
3

Optimized Build

Rebuilds Python using profile data to optimize hot code paths

Alternative Install (Multiple Versions)

To install alongside existing Python versions without overwriting:
This installs Python as python3.15 instead of python3, allowing multiple versions to coexist.
For example, you can have python3.14, python3.15, and python3 (symlink to default) all installed simultaneously.

Out-of-Tree Build

Build in a separate directory to keep source tree clean:
Useful for testing different configurations:

Building on macOS

macOS builds require special considerations for framework builds and universal binaries.

Standard macOS Build

Framework Build

For native macOS app integration:
Framework builds integrate better with macOS applications and IDEs but are not required for command-line use.

Universal Binary (Apple Silicon)

To build for both Intel and Apple Silicon:
For more details, see Mac/README.rst in the source tree.

Building on Windows

Windows builds use Microsoft Visual Studio or Clang.

Prerequisites

1

Install Visual Studio

Install Visual Studio 2017 or later with:
  • Python workload
  • Python native development component
2

Optional: Install Python

Optionally install Python 3.10+ (used by build scripts if available)

Visual Studio Build

1

Get Source

Clone the repository or download source archive:
2

Build

Run the build script from PCbuild directory:
This builds 64-bit Release configuration by default.
3

Test

Run the test suite:

Build Options

Profile-Guided Optimization (Windows)

For maximum performance on Windows:
This performs:
  1. PGInstrument build - Creates instrumented binaries
  2. Runs training workload
  3. PGUpdate build - Creates optimized binaries using profile data
PGO requires Premium Edition of Visual Studio. Community Edition also works for most scenarios.

Using Clang on Windows

To build with Clang/LLVM:
For specific Clang version:

Building Installer

To create Windows installer packages:
See Tools/msi/README.txt for details.

Post-Installation

Verify Installation

Set Up Environment

Add Python to your PATH (if not already done):

Install pip and setuptools

If pip is not included, bootstrap it:

Platform-Specific Notes

Linux Distributions

FreeBSD and OpenBSD

Custom OpenSSL

To use a custom OpenSSL installation:
1

Download and Build OpenSSL

2

Build Python with Custom OpenSSL

Patch releases of OpenSSL have backward-compatible ABI. You can update OpenSSL without recompiling Python.

Troubleshooting

Common Build Issues

Error: configure: error: no acceptable C compiler foundSolution: Install build tools:
Error: Could not build the ssl moduleSolution: Install OpenSSL development files:
Error: Some tests fail during make testSolution:
  • Check if only optional feature tests are failing
  • Review test output for actual errors vs. skipped tests
  • File a bug report if genuine test failures occur
Error: Permission denied during make installSolution: Either use sudo or install to user directory:
Error: Compilation fails with memory errorsSolution: Reduce parallel jobs:

Clean Build

If you encounter persistent issues, try a clean build:

Windows-Specific Issues

Run the build from “Developer Command Prompt for VS” or ensure Visual Studio is properly installed with C++ tools.
Install Python 3.10+ or let build.bat download Python via NuGet automatically.

Performance Tuning

For production deployment:

Memory Allocator

For better memory performance:

Next Steps

Quick Start

Start writing Python code immediately

Python Tutorial

Learn Python language fundamentals

Developer Guide

Contributing to CPython development

C API Reference

Extend Python with C/C++

Additional Resources