A tiny but mighty Bash script to make Python virtual environment management effortless β especially for macOS users who work with Python daily.
python-venv-helper simplifies the venv workflow.
No more remembering environment names or typing out long commands like:
python3 -m venv .venv
source .venv/bin/activate
which pythonInstead, you just run:
source venvThe script will automatically:
- β Check if a virtual environment already exists in your current directory
- π Create one named
.venvif it doesnβt - βοΈ Activate it
- π Show which Python executable is being used
-
Copy the script to your system path (e.g.,
/usr/local/bin/):sudo cp venv /usr/local/bin/venv
-
Make it executable:
sudo chmod +x /usr/local/bin/venv
π‘ Tip: On Apple Silicon / modern macOS,
/usr/local/binis typically in yourPATH.
If not, you can use/opt/homebrew/binor another directory in your path.
In any Python project directory, simply run:
source venvThe script will either create or activate your local virtual environment.
$ cd ~/projects/mytool
source venv
Virtual environment not found. Creating a new one...
Virtual environment created successfully. Activating...
Upgrading pip to the latest version...
Requirement already satisfied: pip in ./venv/lib/python3.13/site-packages (25.2)
Using Python interpreter: /Users/you/projects/mytool/.venv/bin/python3
(venv) $Next time you return to that folder, the same command reactivates the existing venv instantly.
- Looks for a
.venv/directory in the current folder. - If missing, runs
python3 -m venv .venv. - Activates via
source .venv/bin/activate. - Prints
which pythonfor confirmation.
This keeps projects isolated and consistent β without needing to remember venv names.
-
Command not found:
Ensure/usr/local/bin(or wherever you placedvenv) is in yourPATH. -
Wrong Python version:
Create your venv with a specific interpreter first, e.g.:/usr/bin/python3.12 -m venv .venv && source .venv/bin/activate
After that,
source venvwill reuse it automatically. -
Permission denied:
Re-run thechmod +x /usr/local/bin/venvstep.
To remove the helper:
sudo rm -f /usr/local/bin/venv(Optional) Remove per-project venvs by deleting their .venv/ directories.
Made with β€οΈ for Python developers who just want to code β not manage environments.