Skip to main content
The bench setup env command creates and configures a Python virtual environment for your bench installation.

Usage

bench setup env [OPTIONS]

Options

--python
string
default:"python3"
Path to Python executable to use for creating the virtual environment.

Examples

Basic Setup

Create virtual environment with default Python 3:
bench setup env

Specify Python Version

Use a specific Python executable:
bench setup env --python python3.11
Or with full path:
bench setup env --python /usr/bin/python3.10

What It Does

1

Create Virtual Environment

Creates an env directory in your bench folder containing an isolated Python environment.Uses either uv (if available) or standard venv module.
2

Upgrade pip

Updates pip to the latest version in the virtual environment.
3

Install wheel

Installs the wheel package for building Python packages.
4

Install Frappe

If the Frappe app exists, installs Frappe and its Python dependencies in editable mode.

Technical Details

Virtual Environment Location

The virtual environment is created at:
~/frappe-bench/env/

Python Executable

After setup, the bench uses:
~/frappe-bench/env/bin/python

Environment Activation

Bench commands automatically use the virtual environment. You don’t need to manually activate it.

UV Support

If uv (a fast Python package installer) is available, bench uses it automatically:
uv venv env --seed --python python3
Otherwise, it falls back to standard venv:
python3 -m venv env

When to Use

Initial Bench Creation

This command is automatically run when you create a new bench with bench init. You rarely need to run it manually.

After Python Upgrade

If you upgrade your system Python version and want to recreate the virtual environment:
rm -rf env
bench setup env --python python3.11
bench setup requirements

Troubleshooting

If you encounter virtual environment issues:
# Remove corrupted environment
rm -rf env

# Recreate it
bench setup env

# Reinstall all app dependencies
bench setup requirements

Source Code

Implementation: bench/bench.py:350 The env() method in the BenchSetup class handles virtual environment creation and Frappe installation.

Build docs developers (and LLMs) love