Deactivate a pipenv environment

Using the shell command exit also works.

This worked for me when using deactivate still left me with the error:

Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated.
No action taken to avoid nested environments.

After using exit I could successfully switch pipenv instances. This could well be a bug and I should probably report it.


UPDATE: See other answers below. As it has been explained, this works for virtualenv, but pipenv works differently.

Just type deactivate on the command line. See the guide here


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.


Just type "exit", it will take you out of shell.

And if you use "deactivate", then probably you will get this error when you again try to enter in the shell.

Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated.
    No action taken to avoid nested environments.

So, it is prefer to use "exit" for quick access.