$ python3 -m venv .venv # Create a virtual environment
$ source .venv/bin/activate # Activate the virtual environment
(.venv) pip install <whatever you need> # Install stuff within the virtual environment
...
(.venv) deactivate
$ [sudo] rm -fR .venv
$ python3 -m venv .venv # Create a virtual environment
$ source .venv/bin/activate # Activate the virtual environment
(.venv) pip install <whatever you need> # Install stuff within the virtual environment
...
(.venv) deactivate
$ [sudo] rm -fR .venv
Can you not write shell scripts on Darwin?
> source .venv/bin/activate # Activate the virtual environment
This is a convenience, not a necessary step. All it does is manipulate a few environment variables. You can just specify the paths to the venv's pip and Python explicitly.
(Of course, you can script around the expectation of those environment variables, if you prefer that workflow.)
Also, pip 22.3 added the ability to install cross-environment, which allows for creating virtual environments much faster `--without-pip` (see e.g. https://zahlman.github.io/posts/2025/01/07/python-packaging-...).
> [sudo] rm -fR .venv
I can't fathom a reason you'd ever need sudo for this cleanup.