Python Setup Guide
Installation, Configuration & Virtual Environments
1. Steps to Install Python
Windows
Step 1: Go to the official Python website:
[Link]
Step 2: Download the latest stable installer (e.g., Python 3.12.x)
Step 3: Run the installer. IMPORTANT: Check the box:
☑ Add Python to PATH
Step 4: Click "Install Now" and wait for installation to complete.
Step 5: Verify the installation by opening Command Prompt and running:
python --version
pip --version
macOS / Linux
macOS comes with Python 2 pre-installed. Install Python 3 using Homebrew (macOS) or your
system's package manager (Linux):
macOS (Homebrew):
brew install python
Ubuntu/Debian:
sudo apt update && sudo apt install python3 python3-pip
Verify:
python3 --version
2. Path Configuration
After installation, Python must be accessible from your terminal/command prompt via the
system PATH.
Windows
Option A: Enable during installation (recommended) — check 'Add Python to PATH'.
Option B: Manually add Python to PATH:
• Open Start Menu → Search 'Environment Variables'
• Click 'Edit the system environment variables'
• Under System Variables, find Path → click Edit
• Add the Python install path, e.g.:
C:\Users\YourName\AppData\Local\Programs\Python\Python312\
C:\Users\YourName\AppData\Local\Programs\Python\Python312\Scripts\
• Click OK and restart your terminal.
macOS / Linux
Add the following to your shell profile file (~/.bashrc, ~/.zshrc, or ~/.bash_profile):
export PATH="/usr/local/bin/python3:$PATH"
Then apply changes:
source ~/.zshrc # or source ~/.bashrc
3. Virtual Environment (venv) Setup
A virtual environment isolates your project's Python packages from the global installation,
preventing version conflicts.
Create a Virtual Environment
Step 1: Navigate to your project directory:
cd your-project-folder
Step 2: Create the virtual environment:
python -m venv venv
This creates a folder named 'venv' inside your project. You can name it anything, but 'venv' or
'.venv' are common conventions.
Step 3: The folder structure looks like:
your-project/
├── venv/
├── [Link]
└── [Link]
4. Activate and Deactivate Virtual Environment
Activate
Windows (Command Prompt):
venv\Scripts\activate
Windows (PowerShell):
.\venv\Scripts\Activate.ps1
macOS / Linux:
source venv/bin/activate
Once activated, your terminal prompt will change to show the environment name:
(venv) user@machine:~/project$
Install Packages Inside the Environment
After activation, use pip to install packages. They stay isolated to this environment:
pip install requests flask pandas
pip freeze > [Link] # save dependencies
pip install -r [Link] # restore dependencies
Deactivate
To exit the virtual environment and return to the global Python:
deactivate
5. Running Multiple Terminals
When working on multiple projects or running multiple services simultaneously, you may need
multiple terminals each with their own virtual environment.
Opening Multiple Terminals
VS Code: Use the '+' icon in the terminal panel to open a new terminal instance. Each can have
a different venv activated.
Windows Terminal: Click the '+' tab to open new tabs or split panes (Alt + Shift + D).
macOS iTerm2: Use Cmd+T for a new tab or Cmd+D to split the pane.
Linux (gnome-terminal): Ctrl+Shift+T for a new tab.
Activating Different Environments Per Terminal
Each terminal session is independent. You can activate different virtual environments in each:
Terminal 1 — Project A:
cd ~/project-a && source venv/bin/activate
python [Link]
Terminal 2 — Project B:
cd ~/project-b && source venv/bin/activate
python [Link]
Using tmux (Advanced)
tmux lets you create multiple terminal sessions, split windows, and keep sessions alive even
when disconnected:
tmux new -s mysession # Start a new session
Ctrl+B then % # Split pane vertically
Ctrl+B then " # Split pane horizontally
Ctrl+B then arrow keys # Switch between panes
tmux attach -t mysession # Re-attach to session
Python Setup Guide — Created with Claude