How to leave/exit/deactivate Python's virtualenv

anonymity
Release: 2019-05-27 10:36:06
Original
6457 people have browsed it

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:~$
Copy after login

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

me@mymachine:~$
Copy after login

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
Copy after login

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.
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!