Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deactivate a pipenv environment

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?

like image 831
tim_xyz Avatar asked Apr 20 '18 15:04

tim_xyz


People also ask

How do I deactivate Pipenv?

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.

How do I deactivate a virtual environment?

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).

How do I enable and disable Virtualenv?

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.

Where are Pipenv environments stored?

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.


2 Answers

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.

like image 71
ButtaKnife Avatar answered Nov 13 '22 20:11

ButtaKnife


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.

like image 35
Williams Avatar answered Nov 13 '22 18:11

Williams