> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/python/cpython/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start Guide

> Get CPython up and running quickly on your system

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

<CardGroup cols={2}>
  <Card title="Download Binary" icon="download">
    Fastest way to get started. Pre-built installers available for all major platforms.
  </Card>

  <Card title="Build from Source" icon="code">
    Full control over features and optimizations. Recommended for development and customization.
  </Card>
</CardGroup>

## Option 1: Install Pre-Built Binary

### On Windows

<Steps>
  <Step title="Download Python">
    Visit [python.org/downloads](https://www.python.org/downloads/) and download the latest Windows installer
  </Step>

  <Step title="Run Installer">
    Double-click the installer and check "Add Python to PATH"
  </Step>

  <Step title="Verify Installation">
    Open Command Prompt and run:

    ```bash theme={null}
    python --version
    ```
  </Step>
</Steps>

<Info>
  You can also install Python from the Microsoft Store for easier updates and management.
</Info>

### On macOS

<Steps>
  <Step title="Download Python">
    Download the macOS installer from [python.org/downloads](https://www.python.org/downloads/)
  </Step>

  <Step title="Install Package">
    Open the downloaded `.pkg` file and follow the installation wizard
  </Step>

  <Step title="Verify Installation">
    Open Terminal and run:

    ```bash theme={null}
    python3 --version
    ```
  </Step>
</Steps>

<Tip>
  Alternatively, use Homebrew: `brew install python3`
</Tip>

### On Linux

Most Linux distributions include Python. To install or update:

<CodeGroup>
  ```bash Ubuntu/Debian theme={null}
  sudo apt update
  sudo apt install python3 python3-pip
  ```

  ```bash Fedora/RHEL/CentOS theme={null}
  sudo dnf install python3 python3-pip
  ```

  ```bash Arch Linux theme={null}
  sudo pacman -S python python-pip
  ```

  ```bash openSUSE theme={null}
  sudo zypper install python3 python3-pip
  ```
</CodeGroup>

## Option 2: Build from Source

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

### Quick Build (Unix/Linux/macOS)

<Steps>
  <Step title="Download Source">
    ```bash theme={null}
    git clone https://github.com/python/cpython.git
    cd cpython
    ```
  </Step>

  <Step title="Configure">
    ```bash theme={null}
    ./configure
    ```
  </Step>

  <Step title="Build">
    ```bash theme={null}
    make -j$(nproc)
    ```
  </Step>

  <Step title="Test">
    ```bash theme={null}
    make test
    ```
  </Step>

  <Step title="Install">
    ```bash theme={null}
    sudo make install
    ```
  </Step>
</Steps>

<Note>
  This installs Python as `python3`. Use `make altinstall` to avoid overwriting your system Python.
</Note>

### Quick Build (Windows)

<Steps>
  <Step title="Install Visual Studio">
    Install Visual Studio 2017 or later with Python workload
  </Step>

  <Step title="Download Source">
    Clone the repository or download from [python.org/downloads/source](https://www.python.org/downloads/source/)
  </Step>

  <Step title="Build">
    Open Command Prompt in the `PCbuild` directory:

    ```bash theme={null}
    build.bat
    ```
  </Step>

  <Step title="Test">
    ```bash theme={null}
    rt.bat -q
    ```
  </Step>
</Steps>

## Your First Python Program

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

### Interactive Mode

Launch the Python interpreter:

```bash theme={null}
python3
```

You'll see the Python prompt:

```python theme={null}
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:

```python theme={null}
>>> 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)
```

<Tip>
  Use `quit()` or `exit()` to leave the interactive interpreter.
</Tip>

### Script Mode

Create a file named `hello.py`:

```python hello.py theme={null}
#!/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:

```bash theme={null}
python3 hello.py
```

Output:

```
Hello, World!
Sum of [1, 2, 3, 4, 5] = 15
```

### Using Modules

Python's standard library provides powerful modules:

```python example.py theme={null}
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:

<CodeGroup>
  ```bash Run a Script theme={null}
  python3 script.py
  ```

  ```bash Interactive Mode theme={null}
  python3
  ```

  ```bash Run Module theme={null}
  python3 -m module_name
  ```

  ```bash Execute Command theme={null}
  python3 -c "print('Hello')"
  ```

  ```bash Check Version theme={null}
  python3 --version
  ```

  ```bash Get Help theme={null}
  python3 --help
  ```
</CodeGroup>

## Virtual Environments

For project isolation, use virtual environments:

<Steps>
  <Step title="Create Virtual Environment">
    ```bash theme={null}
    python3 -m venv myproject
    ```
  </Step>

  <Step title="Activate">
    <CodeGroup>
      ```bash Unix/macOS theme={null}
      source myproject/bin/activate
      ```

      ```bash Windows theme={null}
      myproject\Scripts\activate
      ```
    </CodeGroup>
  </Step>

  <Step title="Install Packages">
    ```bash theme={null}
    pip install requests numpy pandas
    ```
  </Step>

  <Step title="Deactivate">
    ```bash theme={null}
    deactivate
    ```
  </Step>
</Steps>

<Info>
  Virtual environments keep your project dependencies isolated and prevent version conflicts.
</Info>

## Package Management with pip

CPython includes `pip`, the Python package installer:

```bash theme={null}
# 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:

<Accordion title="Unix/Linux/macOS">
  Add Python to your PATH in `~/.bashrc` or `~/.zshrc`:

  ```bash theme={null}
  export PATH="/usr/local/bin:$PATH"
  ```

  Then reload: `source ~/.bashrc`
</Accordion>

<Accordion title="Windows">
  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`)
</Accordion>

### Permission Denied

On Unix systems, use `sudo make install` or install to a user directory:

```bash theme={null}
./configure --prefix=$HOME/.local
make
make install
```

### Import Errors

If modules can't be imported, check your Python path:

```python theme={null}
import sys
print(sys.path)
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Installation Guide" icon="gear" href="/installation">
    Detailed installation instructions for all platforms and build options
  </Card>

  <Card title="Python Tutorial" icon="book" href="https://docs.python.org/3/tutorial/">
    Official Python tutorial covering language features
  </Card>

  <Card title="Standard Library" icon="books" href="https://docs.python.org/3/library/">
    Explore Python's comprehensive standard library
  </Card>

  <Card title="Contributing" icon="code-branch" href="https://devguide.python.org/">
    Learn how to contribute to CPython development
  </Card>
</CardGroup>

<Warning>
  Always use virtual environments for your projects to avoid dependency conflicts!
</Warning>

## Quick Reference

Common Python interpreter options:

| Option   | Description                                 |
| -------- | ------------------------------------------- |
| `-c cmd` | Execute Python command                      |
| `-m mod` | Run library module as script                |
| `-i`     | Enter interactive mode after running script |
| `-v`     | Verbose output (trace imports)              |
| `-O`     | Optimize bytecode                           |
| `-B`     | Don't write `.pyc` files                    |
| `-u`     | Unbuffered output                           |

That's it! You're now ready to start developing with CPython. Happy coding!
