Set up virtual environment for Python using Anaconda

If you are dealing with the problem of setting up an environment in anaconda and don’t have any idea why do we have to deal with the pain of setting up the environment then this is the right place for you.


Anaconda is an open source software that contains Jupyter, spyder, etc that are used for large data processing, data analytics, heavy scientific computing. Anaconda works for R and Python programming language. Package versions are managed by the package management system conda. 

Installing Anaconda : 

Head over to and install the latest version of Anaconda. Make sure to download the “Python 3.7 Version” for the appropriate architecture. Refer to the below articles for the detailed information on installing anaconda on different platforms. 

Why do we need to set up a virtual environment ?

Like many other languages Python requires a different version for different kind of applications. The application needs to run on a specific version of the language because it requires a certain dependency that is present in older versions but changes in newer versions. Virtual environments makes it easy to ideally separate different applications and avoid problems with different dependencies. Using virtual environment we can switch between both applications easily and get them running.

There are multiple ways of creating an environment using virtualenv, venv and conda. Conda command is preferred interface for managing intstallations and virtual environments with the Anaconda Python distribution.


Let’s go through the steps of creating a virtual environment using conda interface:


Step 1: Check if conda is installed in your path.

conda -V


Step 2: Update the conda environment 

conda update conda

Step 3: Set up the virtual environment

conda create -n envname python=x.x anaconda

Let’s create a virtual environment name Geeks for Python3.6

Step 4: Activating the virtual environment

conda activate envname


 When conda environment is activated it modifies the PATH and shell variables points specifically to the isolated Python set-      up you created.


Step 5: Installation of required packages to the virtual environment

conda install -n yourenvname package

Step 6: Deactivating the virtual environment

conda deactivate

Step 7: Deletion of virtual environment

conda remove -n envname -all


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

Article Tags :