Virtual Environment in Python
CREATED BY @ KAVI.S_NETWORK
Python Virtual Environment Setup (Cross-Platform Guide)
Windows Setup (with Permission Fix)
Step 1: Install Python
• Download from https://python.org
• During installation, check "Add Python to PATH"
Step 2: Create Virtual Environment
python -m venv venv
Step 3: Fix Permission (First Time Only)
If activation throws an error:
File activate.ps1 cannot be loaded because running scripts is disabled on this system.
Open PowerShell as Administrator and run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Choose Y to confirm.
Step 4: Activate Virtual Environment
.\venv\Scripts\Activate.ps1
Or if using CMD:
venv\Scripts\activate.bat
Linux Setup
Step 1: Install Python (if needed)
sudo apt update
sudo apt install python3 python3-venv -y
Step 2: Create Virtual Environment
python3 -m venv venv
Step 3: Activate Virtual Environment
source venv/bin/activate
macOS Setup
Step 1: Install Python
Use either Homebrew or download manually:
brew install python
Step 2: Create Virtual Environment
python3 -m venv venv
Step 3: Activate Virtual Environment
source venv/bin/activate
(Optional) Fix Permission Denied (Rare)
chmod +x venv/bin/activate
After Activation (All Platforms)
Test Installation:
pip install requests
Confirm it's using venv:
which python # or 'where python' on Windows
which pip # or 'where pip'
Should show paths inside your venv/ folder.
Final Tip:
Each project should have its own virtual environment to avoid version conflicts.
Use deactivate to exit the venv when done.