How to leave/exit/deactivate a Python virtualenv

ID : 434

viewed : 52

Tags : pythonvirtualenvvirtualenvwrapperpython

Top 5 Answer for How to leave/exit/deactivate a Python virtualenv

vote vote

93

Usually, activating a virtualenv gives you a shell function named:

$ deactivate 

which puts things back to normal.

I have just looked specifically again at the code for virtualenvwrapper, and, yes, it too supports deactivate as the way to escape from all virtualenvs.

If you are trying to leave an Anaconda environment, the command depends upon your version of conda. Recent versions (like 4.6) install a conda function directly in your shell, in which case you run:

conda deactivate 

Older conda versions instead implement deactivation using a stand-alone script:

source deactivate 
vote vote

82

Use:

$ deactivate  

If this doesn't work, try

$ source deactivate 

Anyone who knows how Bash source works will think that's odd, but some wrappers/workflows around virtualenv implement it as a complement/counterpart to source activate. Your mileage may vary.

vote vote

79

I defined an alias, workoff, as the opposite of workon:

alias workoff='deactivate' 

It is easy to remember:

[bobstein@host ~]$ workon django_project (django_project)[bobstein@host ~]$ workoff [bobstein@host ~]$ 
vote vote

67

To activate a Python virtual environment:

$cd ~/python-venv/ $./bin/activate 

To deactivate:

$deactivate 
vote vote

58

To activate a Python virtual environment:

source venv/bin/activate 

Note: Here "venv" is your virtualenvironment folder name

To deactivate :

deactivate 

or

source deactivate 

Top 3 video Explaining How to leave/exit/deactivate a Python virtualenv

Related QUESTION?