0% found this document useful (0 votes)
4 views4 pages

Python Setup Guide

The Python Setup Guide provides detailed steps for installing Python on Windows, macOS, and Linux, including path configuration and verification. It also covers creating and managing virtual environments to isolate project dependencies, along with instructions for activating and deactivating these environments. Additionally, the guide explains how to manage multiple terminal sessions for different projects and introduces the use of tmux for advanced terminal management.

Uploaded by

Bushra Anjum
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Python Setup Guide

The Python Setup Guide provides detailed steps for installing Python on Windows, macOS, and Linux, including path configuration and verification. It also covers creating and managing virtual environments to isolate project dependencies, along with instructions for activating and deactivating these environments. Additionally, the guide explains how to manage multiple terminal sessions for different projects and introduces the use of tmux for advanced terminal management.

Uploaded by

Bushra Anjum
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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

You might also like