Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Deactivating a Virtual Environment

Give Feedback

When you’re done working on a project, you may want to go back to using the global Python or switch to a different virtual environment. This is easy to do using the deactivate command. In this lesson you’ll see how to deactivate and re-activate virtual environments.

koinonia9912 on July 23, 2020

Please consider discussing virtual environments when using miniconda3 and anaconda3 and also using pip3 all on same machine, and how to avoid complications. Also, if the system-wide install environment has no name when using pip3 but has the name (base) in conda environment?

(base) C:\Users\CCH>conda env list

                     C:\Users\CCH\Anaconda3

base * C:\Users\CCH\Anaconda3_32bit

Following RP module steps *********** (base) C:\Users\CCH>mkdir my_python_projects

(base) C:\Users\CCH>cd my_python_projects

(base) C:\Users\CCH\my_python_projects>mkdir venvs

(base) C:\Users\CCH\my_python_projects>cd venvs

(base) C:\Users\CCH\my_python_projects\venvs>where conda C:\Users\CCH\Anaconda3_32bit\Library\bin\conda.bat C:\Users\CCH\Anaconda3_32bit\Scripts\conda.exe C:\Users\CCH\Anaconda3\condabin\conda.bat C:\Users\CCH\Anaconda3\Scripts\conda.exe

(base) C:\Users\CCH\my_python_projects\venvs>dir Volume in drive C is Windows Volume Serial Number is F8EC-18BD Directory of C:\Users\CCH\my_python_projects\venvs 07/22/2020 04:19 PM <DIR> . 07/22/2020 04:19 PM <DIR> .. 07/22/2020 04:19 PM <DIR> venvPy3.8-32 0 File(s) 0 bytes 3 Dir(s) 317,172,707,328 bytes free

(base) C:\Users\CCH\my_python_projects\venvs>cd venvPy3.8-32

(base) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32>dir Volume in drive C is Windows Volume Serial Number is F8EC-18BD Directory of C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32 07/22/2020 04:19 PM <DIR> . 07/22/2020 04:19 PM <DIR> .. 07/22/2020 04:19 PM <DIR> Include 07/22/2020 04:19 PM <DIR> Lib 07/22/2020 04:19 PM 118 pyvenv.cfg 07/22/2020 04:20 PM <DIR> Scripts 1 File(s) 118 bytes

(base) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32>cd Lib

(base) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib>dir Volume in drive C is Windows Volume Serial Number is F8EC-18BD Directory of C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib 07/22/2020 04:19 PM <DIR> . 07/22/2020 04:19 PM <DIR> .. 07/22/2020 04:20 PM <DIR> site-packages 0 File(s) 0 bytes 3 Dir(s) 317,175,427,072 bytes free

(base) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib>cd site-* (base) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib\site-packages>dir Volume in drive C is Windows Volume Serial Number is F8EC-18BD Directory of C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib \site-packages 07/22/2020 04:20 PM <DIR> . 07/22/2020 04:20 PM <DIR> .. 07/22/2020 04:19 PM 126 easy_install.py 07/22/2020 04:20 PM <DIR> pip 07/22/2020 04:20 PM <DIR> pip-19.2.3.dist-info 07/22/2020 04:19 PM <DIR> pkg_resources 07/22/2020 04:19 PM <DIR> setuptools 07/22/2020 04:19 PM <DIR> setuptools-41.2.0.dist-info 07/22/2020 04:19 PM <DIR> pycache 1 File(s) 126 bytes 8 Dir(s) 317,174,956,032 bytes free 1

(base) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib\site-packages>deactivate DeprecationWarning: ‘deactivate’ is deprecated. Use ‘conda deactivate’.

(base) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib \site-packages>conda.bat deactivate

C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib \site-packages>cd ..

C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Lib>cd ../Scripts

C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Scripts>dir Volume in drive C is Windows Volume Serial Number is F8EC-18BD Directory of C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32 \Scripts 07/22/2020 04:20 PM <DIR> . 07/22/2020 04:20 PM <DIR> .. 07/22/2020 04:20 PM 2,326 activate 07/22/2020 04:20 PM 995 activate.bat 07/22/2020 04:20 PM 18,454 Activate.ps1 07/22/2020 04:20 PM 368 deactivate.bat 07/22/2020 04:19 PM 93,080 easy_install-3.8.exe 07/22/2020 04:19 PM 93,080 easy_install.exe 07/22/2020 04:20 PM 93,062 pip.exe 07/22/2020 04:20 PM 93,062 pip3.8.exe 07/22/2020 04:20 PM 93,062 pip3.exe 07/22/2020 04:19 PM 420,936 python.exe 07/22/2020 04:19 PM 419,912 pythonw.exe 07/22/2020 04:19 PM 559,104 pythonw_d.exe 07/22/2020 04:19 PM 560,640 python_d.exe 13 File(s) 2,448,081 bytes 2 Dir(s) 317,173,010,432 bytes free

C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Scripts>activate

(venvPy3.8-32) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32 \Scripts>where python C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Scripts\python.exe C:\Users\CCH\Anaconda3\python.exe C:\Users\CCH\AppData\Local\Programs\Python\Python38-32\python.exe

(venvPy3.8-32) C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32 \Scripts>deactivate C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Scripts>python Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32 Type “help”, “copyright”, “credits” or “license” for more information.

exit()

C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32\Scripts>conda env list

conda environments:

base * C:\Users\CCH\Anaconda3 C:\Users\CCH\Anaconda3_32bit C:\Users\CCH\my_python_projects\venvs\venvPy3.8-32 \Scripts>cd C:\Users\CCH\Anaconda3_32bit

C:\Users\CCH\Anaconda3_32bit>conda deactivate

C:\Users\CCH\Anaconda3_32bit>conda deactivate

C:\Users\CCH\Anaconda3_32bit>conda env list

conda environments:

base * C:\Users\CCH\Anaconda3 C:\Users\CCH\Anaconda3_32bit

C:\Users\CCH\Anaconda3_32bit>conda activate .

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3_32bit>where pip3 C:\Users\CCH\AppData\Local\Programs\Python\Python38-32\Scripts\pip3.exe

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3_32bit>conda list

EnvironmentLocationNotFound: Not a conda environment: C:\Users\CCH\Anaconda3\envs

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3_32bit>pip3 list Package Version

pip 19.2.3 setuptools 41.2.0

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3_32bit>conda env list

conda environments:

base C:\Users\CCH\Anaconda3 C:\Users\CCH\Anaconda3_32bit

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3_32bit>python Python 3.7.6 (default, Jan 8 2020, 16:21:45) [MSC v.1916 32 bit (Intel)] :: Anaconda, Inc. on win32 Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment please see conda.io/activation Type “help”, “copyright”, “credits” or “license” for more information.

exit()

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3_32bit>pip3 list Package Version

pip 19.2.3 setuptools 41.2.0

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3_32bit> where python.exe C:\Users\CCH\Anaconda3_32bit\python.exe C:\Users\CCH\Anaconda3\python.exe C:\Users\CCH\AppData\Local\Programs\Python\Python38-32\python.exe

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3_32bit> cd ..\Anaconda3\envs

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3\envs>cd ..

(C:\Users\CCH\Anaconda3\envs) C:\Users\CCH\Anaconda3>conda deactivate

C:\Users\CCH\Anaconda3>activate base

C:\Users\CCH\Anaconda3>conda.bat activate base

(base) C:\Users\CCH\Anaconda3>where pip C:\Users\CCH\Anaconda3\Scripts\pip.exe C:\Users\CCH\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe

(base) C:\Users\CCH\Anaconda3>conda env list

conda environments:

base * C:\Users\CCH\Anaconda3 C:\Users\CCH\Anaconda3_32bit

(base) C:\Users\CCH\Anaconda3>

I was able to change the default python environment 
in Visual Studio 2019

Become a Member to join the conversation.