This is a specific article with has the content or subject about python virtual environment. The focus is about how to deactivate a python virtual environment. There is a previous article for activating python virtual environment in this link with the title of ‘How to Activate Python Virtual Environment’. There are a few steps for deactivating the python virtual environment. It actually depends on the python virtual environment which is currently run and active. The following are those steps :
Check the python virtual environment first. Usually, the name of the python virtual environment exist in the front of the bash prompt. For an example check the following lines :
The python virtual environment has a name of ‘python-env’. In order to search for the location or the folder of the python virtual environment, just execute the following command :
(python-env) root@hostname:~# which python /root/python-env/bin/python (python-env) root@hostname:~#
According to the output of the above command, the location of the folder is in ‘/root/python-env’.
Deactivating the python virtual environment
The process for deactivating the python virtual environment is quite simple. Just type ‘deactivate’ in the command line as follows :
(python-env) user@hostname:~# deactivate user@hostname:~#
The above python virtual environment name is ‘python-env’. The folder containing the necessary library is also has the name of ‘python-env’. Although the execution is not inside in the folder with the name of ‘python-env’, the deactivation process is still a success. As long as it is running in the python virtual environment, the command ‘deactivate’ for deactivating the python virtual environment can be done anywhere. It other words, the execution of the command is in the active python virtual environment. For further reference, read the article with the title of ‘How to Activate Python Virtual Environment’ in this link to learn how to activate python virtual environment.
Actually, there is another type of python virtual environment which is specifically for anaconda distribution. It is one of the type of python distribution and it includes all of packages and also tools ready for use. It is basically containing all of the necessary equipment from the packages, tools even its own python distribution within. :
(base) user@hostname:~$ conda deactivate user@hostname:~$
The python virtual environment exist with the name of ‘base’. Just type ‘conda deactivate’ in any working directory as long as it is running in the python virtual environment of anaconda. The following is the location of the anaconda distribution python just to show the exact location as an additional information :
(base) user@hostname:~$ which python /home/user/anaconda3/bin/python (base) user@hostname:~$