snippetpythonCriticalCanonical
How to leave/exit/deactivate a Python virtualenv
Viewed 0 times
leavehowexitvirtualenvpythondeactivate
Problem
I'm using virtualenv and the virtualenvwrapper. I can switch between virtualenv's just fine using the
How do I exit all virtual environments and work on my system environment again? Right now, the only way I have of getting back to
workon command.me@mymachine:~$ workon env1
(env1)me@mymachine:~$ workon env2
(env2)me@mymachine:~$ workon env1
(env1)me@mymachine:~$How do I exit all virtual environments and work on my system environment again? Right now, the only way I have of getting back to
me@mymachine:~$ is to exit the shell and start a new one. That's kind of annoying. Is there a command to work on "nothing", and if so, what is it? If such a command does not exist, how would I go about creating it?Solution
Usually, activating a virtualenv gives you a shell function named:
which puts things back to normal.
I have just looked specifically again at the code for
If you are trying to leave an Anaconda environment, the command depends upon your version of
Older conda versions instead implement deactivation using a stand-alone script:
$ deactivatewhich 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 deactivateOlder conda versions instead implement deactivation using a stand-alone script:
source deactivateCode Snippets
$ deactivateconda deactivatesource deactivateContext
Stack Overflow Q#990754, score: 4541
Revisions (0)
No revisions yet.