Automatic virtual environment resolution — never type 'source .venv/bin/activate' again
Project description
venv-proxy
Never type source .venv/bin/activate again.
Not you. Not your AI agent.
pip install venv-proxy
venv-proxy install
That's it. From now on, python and pip automatically use the right .venv — in any directory, in any shell, for any process.
The problem
Every Python project has a .venv. Activating it is a manual step that breaks constantly:
# You forget it. Your agent ignores it. CI doesn't have it.
source .venv/bin/activate # ← this shouldn't exist
When skipped, pip install pollutes your global Python. Dependencies conflict. Projects break silently.
AI coding agents (Claude Code, Cursor, Copilot) make this worse. They execute shell commands without TTY activation. They ignore your CLAUDE.md instructions. They install packages wherever they want.
Real issue: anthropics/claude-code #9368 — duplicated 4 times, still open.
How it works
venv-proxy installs lightweight shims for python, python3, pip, and pip3 at the front of your PATH.
When invoked from any directory, each shim:
- Walks up the filesystem from your current directory
- Finds the nearest
.venv/bin/folder - Replaces itself with the correct binary via
execv()— zero overhead, fully transparent - Falls back to system Python if no
.venvis found
my-project/
├── .venv/ ← found automatically
│ └── bin/
│ ├── python ← used by shim
│ └── pip ← used by shim
├── src/
│ └── main.py
└── tests/
└── test_main.py ← python here uses .venv too
Install
pip install venv-proxy
venv-proxy install
# Add to your shell profile if not already there:
export PATH="$HOME/.local/bin:$PATH"
Usage
# Before venv-proxy:
cd my-project
source .venv/bin/activate # don't forget!
pip install requests # now in .venv
python main.py
# After venv-proxy:
cd my-project
pip install requests # automatically in .venv ✓
python main.py # automatically uses .venv ✓
Works the same for AI agents — no config, no CLAUDE.md instructions needed.
Commands
venv-proxy install # install shims into ~/.local/bin
venv-proxy uninstall # remove shims
venv-proxy status # show which venv would be used from CWD
venv-proxy doctor # diagnose PATH and shim issues
Debug mode
VENV_PROXY_DEBUG=1 python script.py
# venv-proxy: using /home/user/my-project/.venv/bin/python
FAQ
Does it work with uv?
Yes. venv-proxy resolves .venv/bin/python regardless of how the venv was created (venv, virtualenv, uv, poetry).
What if there's no .venv?
Falls back to system Python transparently.
Does it slow things down?
No. It uses os.execv() which replaces the current process — there's no subprocess or wrapper overhead.
Does it work in CI?
Yes. Any process that calls python or pip gets the right venv automatically.
Windows?
Not yet. Linux and macOS only for now.
Requirements
- Python 3.9+
- Linux or macOS
Contributing
Contributions are welcome! See CONTRIBUTING.md for setup instructions.
License
MIT
Built because this GitHub issue has been open too long.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file venv_proxy-0.1.0.tar.gz.
File metadata
- Download URL: venv_proxy-0.1.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13163c0e9c192141da10033514f5146b0b3bf63f850a01c9b4852993a0febe9e
|
|
| MD5 |
77b44da8e8910357df82cd116ef84184
|
|
| BLAKE2b-256 |
741e3a4a01662510b78161197e61cee449f829e88e9598aa4f1085d0096656e3
|
File details
Details for the file venv_proxy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: venv_proxy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f33b29a7423924a9129951e47e4506d95a238526cd2d42ed9db5bed8e6f66f5
|
|
| MD5 |
b98e971ab924f5f74fcfe686ff164014
|
|
| BLAKE2b-256 |
5c53da6e4604c03a0cf9f21089ae8ba6f3e7232cb81e066776214ef42bf609ee
|