Python: venv start
Uiterlijk
Create & activate
In your project root
python3 -m venv .venv
Activate in zsh/bash
source .venv/bin/activate
Verify
python -V
Prepends .venv/bin to PATH, so python, pip, and any console scripts installed in the venv are found first. Sets a few Python-related vars (e.g., VIRTUAL_ENV, PYTHONHOME unset).
When running script change the shebang to the venv path as well:
#!/Users/username/.python
Deactivating, uninstalling, removing
Leave the venv
deactivate
Uninstall a package (inside the venv)
source .venv/bin/activate python -m pip uninstall <pkg>
Remove ALL packages but keep the venv structure
python -m pip freeze | xargs -r python -m pip uninstall -y
Nuke the venv directory
deactivate 2>/dev/null || true rm -rf .venv/