Installation

macOS

macOS may come with an older Python. Install the latest:

# Using Homebrew (recommended)
brew install python
 
# Or download from python.org

Download link: python.org/downloads — get Python 3.10 or higher.

Windows

  1. Download the installer from python.org/downloads
  2. Check “Add python.exe to PATH” during installation
  3. Click Install Now

Linux

# Debian/Ubuntu
sudo apt update && sudo apt install python3 python3-pip python3-venv
 
# Fedora
sudo dnf install python3 python3-pip

Verify Installation

python3 --version   # or just `python --version` on Windows
pip3 --version

Virtual Environment

Always use a virtual environment to keep your project dependencies isolated.

Create

python3 -m venv venv

Activate

# macOS/Linux
source venv/bin/activate
 
# Windows (PowerShell)
.\venv\Scripts\Activate
 
# Windows (CMD)
venv\Scripts\activate.bat
 
# Fish shell
source venv/bin/activate.fish

Deactivate

deactivate

Install Dependencies

With your virtual environment active:

pip install flask   # or whatever your project needs
pip freeze > requirements.txt   # save dependencies

To reinstall later:

pip install -r requirements.txt