Python virtual environments

Installing packages

Python packages can be installed:

One may not want to cause changes to their system by installing Python packages in either of these two locations; instead, they can use self-contained virtual environments.

Using virtual environments

$ python3 -m venv myenv             # Create the environment
$ source myenv/bin/activate         # Enter the environment
$ (myenv) pip list                  # Notice the prompt changed
$ deactivate                        # Leave the environment, back to "normal"
$ pip list                          # Will show a different list of packages

More tools