Deactivate a pipenv environment

tim_xyz picture tim_xyz · Apr 20, 2018 · Viewed 37.3k times · Source

How can I deactivate my pipenv environment?

With other tools I've been able to do something like source deactivate, but that has no affect here.

Create an environment:

pipenv --three

Activate the environment:

source $(pipenv --venv)/bin/activate

But how to deactivate?

Answer

ButtaKnife picture ButtaKnife · Jun 28, 2018

To elaborate on Williams' answer a bit more, the expected workflow is to enter the virtualenv using pipenv shell. When you activate the virtualenv that way, the console output now indicates to use exit:

Spawning environment shell (/bin/zsh). Use 'exit' to leave.

Trying to exit the virtualenv with deactivate will leave pipenv in a confused state because you will still be in that spawned shell instance but not in an activated virtualenv.