Skip to main content

Command Palette

Search for a command to run...

How to Set Up ERPNext Bench Using a Python Virtual Environment on WSL (Windows)

Published
2 min read

If you’re setting up ERPNext on a Windows machine using WSL (Windows Subsystem for Linux) and encounter Python installation errors like:

error: externally-managed-environment

yaml Copy Edit

This is because your system is PEP 668-compliant, which restricts system-wide pip installations.


Solution: Use a Virtual Environment

We’ll fix this by using a Python virtual environment just for your ERPNext/Bench setup.


🔧 Step-by-Step: Install Bench Using a Virtual Environment

1. Install python3-venv if not already installed

sudo apt update
sudo apt install python3-venv -y
2. Create a Virtual Environment
bash
Copy
Edit
python3 -m venv ~/.bench-env
3. Activate the Environment
bash
Copy
Edit
source ~/.bench-env/bin/activate
Your terminal should now show a virtual environment prefix:

bash
Copy
Edit
(.bench-env) user@COLLINS:~
4. Install Bench Inside the Environment
bash
Copy
Edit
pip install frappe-bench
5. Verify Installation
bash
Copy
Edit
bench --version
6. Navigate to Your ERPNext Directory and Start Your Site
bash
Copy
Edit
cd ~/erpnext-dev
bench use demo-erp
bench start
 Bonus: Reactivating the Virtual Environment on New Sessions
Each time you reopen your terminal and want to use bench, remember to activate the virtual environment again:

bash
Copy
Edit
source ~/.bench-env/bin/activate
Then navigate to your ERPNext folder:

bash
Copy
Edit
cd ~/erpnext-dev
🎉 That’s It!
You now have a safe, isolated Python environment for your ERPNext development on WSL, and bench is up and running properly.