Beginner

Installation & Setup

Get Python installed on your machine, configure your development environment, and write your first script.

Installing Python

Python is available for all major operating systems. Download the latest version from python.org.

Windows

  1. Download the Installer

    Go to python.org/downloads and download the latest Python 3.x installer for Windows.

  2. Run the Installer

    Important: Check the box that says "Add Python to PATH" before clicking "Install Now."

  3. Verify Installation

    Open Command Prompt and type:

Command Prompt
python --version
# Output: Python 3.12.x

pip --version
# Output: pip 24.x from ...

macOS

Terminal
# Using Homebrew (recommended)
brew install python

# Verify
python3 --version
pip3 --version

Linux (Ubuntu/Debian)

Terminal
# Update and install
sudo apt update
sudo apt install python3 python3-pip python3-venv

# Verify
python3 --version
pip3 --version

Setting Up PATH

💡
What is PATH? PATH is an environment variable that tells your operating system where to find executables. When you type python in the terminal, the OS looks through PATH directories to find the Python executable.

If you forgot to check "Add to PATH" during Windows installation, you can add it manually via System Properties → Environment Variables → Edit PATH → add the Python installation directory (e.g., C:\Python312\ and C:\Python312\Scripts\).

pip Package Manager

pip is Python's package installer. It comes bundled with Python 3.4+ and lets you install third-party libraries from PyPI.

Terminal
# Install a package
pip install requests

# Install a specific version
pip install requests==2.31.0

# Upgrade a package
pip install --upgrade requests

# List installed packages
pip list

# Uninstall a package
pip uninstall requests

# Generate requirements file
pip freeze > requirements.txt

# Install from requirements file
pip install -r requirements.txt

Virtual Environments

Virtual environments create isolated Python environments for each project, preventing dependency conflicts between projects.

Terminal
# Create a virtual environment
python3 -m venv myproject_env

# Activate it (macOS/Linux)
source myproject_env/bin/activate

# Activate it (Windows)
myproject_env\Scripts\activate

# Your prompt changes to show the env name
(myproject_env) $ pip install requests

# Deactivate when done
deactivate
Best practice: Always create a virtual environment for each project. This ensures dependencies are isolated and reproducible.

IDEs and Editors

IDE/EditorBest ForKey Features
VS CodeGeneral-purpose developmentFree, extensions, integrated terminal, Git, Python extension
PyCharmProfessional Python developmentIntelligent code completion, debugger, testing, Community (free) & Pro editions
Jupyter NotebookData science & explorationInteractive cells, inline visualization, markdown support
Sublime TextLightweight editingFast, minimal, extensible, multi-cursor editing

Running Python Scripts

Create a file called hello.py with any text editor:

hello.py
# My first Python script
name = input("What is your name? ")
print(f"Hello, {name}! Welcome to Python.")

Run it from the terminal:

Terminal
python3 hello.py
# What is your name? Alice
# Hello, Alice! Welcome to Python.

Python Version Management (pyenv)

If you need to work with multiple Python versions, pyenv lets you install and switch between them easily:

Terminal
# Install pyenv (macOS/Linux)
curl https://pyenv.run | bash

# Install a specific Python version
pyenv install 3.12.0
pyenv install 3.11.6

# Set global default
pyenv global 3.12.0

# Set local version for a project
cd myproject
pyenv local 3.11.6