how to exit virtual environment in python code example Example 1: how to exit virtualenv $ deactivate Example 2: exit venv python $ deactivate