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?
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.
You can deactivate a virtual environment by typing “deactivate” in your shell. The exact mechanism is platform-specific and is an internal implementation detail (typically a script or shell function will be used).
There is a command to workon "nothing" - it displays all your available virtual environments, which is pretty nifty. Just type "workon" with no arguments and hit enter. The command to leave is "deactivate", as answered below. Does closing the shell deactivate all the environments used the shell session.
pipenv stores the packages inside your local machines shared directory called virtualenvs (~/. local/share/virtualenvs/<env-name> ). It ensures that you don't need to use pip and virtualenv separately.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With