A lightweight replacement for virtualenvwrapper when using uv.
uv is a fantastic, high-performance tool for managing Python packages and virtual environments. However, it currently lacks a built-in way to easily manage multiple named environments in a centralized location (see feature request).
uv-virtualenvwrapper
fills this gap by providing a simple bash/zsh script with tab completion, mirroring the core functionality of virtualenvwrapper specifically for use with uv. It allows for quick creation, activation, removal, and listing of named Python virtual environments. Virtual environments are stored centrally in ~/.virtualenvs
by default and can be activated with workon <name>
. Pre/postactivate hooks from virtualenvwrapper are not supported.
- Download the script: Download uv-virtualenvwrapper.sh.
- Add to shell config:
Add
to your shell configuration file (
source /path/to/uv-virtualenvwrapper.sh
~/.bashrc
or~/.zshrc
).
- Install uv-virtualenvwrapper:
uv tool install uv-virtualenvwrapper
- Add to shell config:
Add
to your shell configuration file (
source $(which uv-virtualenvwrapper.sh)
~/.bashrc
or~/.zshrc
).
Command | Description |
---|---|
mkvirtualenv [options] <name> |
Creates a new virtual environment named <name> and activates it. All options are passed to uv venv --seed . |
workon [name] |
Activates the virtual environment named <name> . If no name is given, lists available environments. |
rmvirtualenv <name> |
Removes the virtual environment named <name> . |
lsvirtualenv |
Lists all available virtual environments. |
deactivate |
Deactivates the current virtual environment. (Standard venv command) |
Virtual environments are stored in WORKON_HOME
(default: ~/.virtualenvs
).
Example:
$ mkvirtualenv myenv
$ uv pip install requests
$ deactivate
[...]
$ workon myenv
$ uv pip list