Home >Backend Development >Python Tutorial >How to leave/exit/deactivate Python's virtualenv

How to leave/exit/deactivate Python's virtualenv

anonymity
anonymityOriginal
2019-05-27 10:36:066652browse

Virtualenv and virtualenvwrapper are being used. It is now possible to switch between virtualenvs using the workon command.

me@mymachine:~$ workon env1
(env1)me@mymachine:~$ workon env2
(env2)me@mymachine:~$ workon env1
(env1)me@mymachine:~$

But, how do I exit all virtual machines and use my real machine again? The only way to exit now

me@mymachine:~$

But after exiting, the shell starts a new interface and the workspace cannot be restored.

How to leave/exit/deactivate Python's virtualenv

Solution:

Normally, activating virtualenv will provide you with a shell function named:

$ deactivate

This brings things back to normal.

I just looked at the code of virtualenvwrapper again and yes it also supports deactivate

as a way to escape all virtualenvs

If you try to leave Anaconda environment, the process is slightly different: run the double-word command source deactivate, because they use a separate script to achieve deactivation.

bash-4.3$ deactivate
pyenv-virtualenv: deactivate must be sourced. Run 'source deactivate' instead of 'deactivate'
bash-4.3$ source deactivate
pyenv-virtualenv: no virtualenv has been activated.

The above is the detailed content of How to leave/exit/deactivate Python's virtualenv. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn