How to leave/exit/deactivate a Python virtualenv
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
How to leave/exit/deactivate a Python virtualenv
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
Deactivate a pipenv environment
UPDATE: See other answers below. As it has been explained, this works for virtualenv
, but pipenv
works differently.
Just type deactivate
on the command line. See the guide here
How to exit pew venv
You just need to type in exit
in your terminal rather than the traditional deactivate
for a venv.
How do I remove/delete a virtualenv?
"The only way I can remove it seems to be:
sudo rm -rf venv
"
That's it! There is no command for deleting your virtual environment. Simply deactivate it and rid your application of its artifacts by recursively removing it.
Note that this is the same regardless of what kind of virtual environment you are using. virtualenv
, venv
, Anaconda environment, pyenv
, pipenv
are all based the same principle here.
how to deactivate virtualenv from a bash script
It'll be hard to make a service like that useful.
. ${VENV}/activate # note the dot
or
source ${VENV}/activate
will source the activate
script, i.e. run its contents as if they were part of the shell or script where you source them. virtualenvironment
's activate
is designed for this usage. In contrast, just executing the script normally with
${VENV}/activate # note: NO dot and NO 'source' command
will run its content in a subshell and won't have any useful effect.
However, your service script will already run in a subshell of its own. So except for any python commands you run as part of the service start process, it won't have any effect.
On the plus side, you won't even have to care about de-activating the environment, unless you want to run even more python stuff in the service start process, but outside of your virtualenv.
Related Topics
Embedding Ipython Qt Console in a Pyqt Application
Removing Horizontal Lines in Image (Opencv, Python, Matplotlib)
Convert from Ascii String Encoded in Hex to Plain Ascii
How to Print Utf-8 Encoded Text to the Console in Python < 3
How to Convert a List to a List of Tuples
Check for Identical Rows in Different Numpy Arrays
Accessing CPU Temperature in Python
In Python, How to Put a Thread to Sleep Until a Specific Time
Python Method Name with Double-Underscore Is Overridden
No Module Named When Using Pyinstaller
What Exactly Is Python's Iterator Protocol
Reference Requirements.Txt for the Install_Requires Kwarg in Setuptools Setup.Py File
Django-Registration & Django-Profile, Using Your Own Custom Form
How to Add Hours to Current Time in Python
How to Control the Mouse in MAC Using Python
Typeerror: 'List' Object Is Not Callable While Trying to Access a List