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.
C
Please check this topic for answer from contributor perspective:
https://github.com/pypa/pipenv/issues/84#issuecomment-275056943
Spoiler :
pipenv starts a new shell session with the virtualenv pathing instead of changing the pathing in the current shell session. That is why deactivate does not work. you need to exit the shell session. the exit command or CTRL-d will do the trick.
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.
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.
First "deactivate" and then "exit" you will get out of the virtual env. As of now this worked for me.