bench setup env command creates and configures a Python virtual environment for your bench installation.
Usage
Options
Path to Python executable to use for creating the virtual environment.
Examples
Basic Setup
Create virtual environment with default Python 3:Specify Python Version
Use a specific Python executable:What It Does
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.Technical Details
Virtual Environment Location
The virtual environment is created at:Python Executable
After setup, the bench uses:Environment Activation
Bench commands automatically use the virtual environment. You don’t need to manually activate it.UV Support
Ifuv (a fast Python package installer) is available, bench uses it automatically:
venv:
When to Use
Initial Bench Creation
This command is automatically run when you create a new bench withbench 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:Troubleshooting
If you encounter virtual environment issues:Related Commands
bench setup requirements- Install Python and Node dependencies for all appsbench pip- Run pip commands in the bench environment
Source Code
Implementation:bench/bench.py:350
The env() method in the BenchSetup class handles virtual environment creation and Frappe installation.