In this article, we will learn how to create and manage a virtual environment using Anaconda on a Windows system. We’ll go step-by-step through the process with simple explanations and commands that you can easily follow.
Prerequisistes
To download and install Anaconda, refer to the linked guides for Windows or Linux installation. Once Anaconda is installed, continue with the steps below.
Why Do We Need a Virtual Environment?
A virtual environment allows you to keep your projects separate from each other. Each environment can have its own version of Python and its own packages. This helps to:
- Avoid conflicts between different project dependencies.
- Work with multiple versions of Python easily.
- Keep your main system clean and organized.
- Remove or recreate environments anytime without affecting others.
Steps to Set Up a Virtual Environment
We’ll be using Anaconda Prompt, which is installed automatically with Anaconda. Let's go through the steps of creating a virtual environment using conda interface:
Step 1: Open Anaconda Prompt
Click on the Start Menu, search for “Anaconda Prompt”, and open it. You will use this prompt to type all conda commands.

Step 2: Check if Conda is Installed
Type the following command and press Enter:
conda -V

If Anaconda is installed correctly, it will show the version number (for example, conda 24.5.0).
Step 3: Update Conda
It is a good practice to update conda before creating an environment. Type the command below and press Enter:
conda update conda
When asked for confirmation, type y and press Enter. This ensures you have the latest version of conda.
Step 4: Check Available Python Versions
You can see which Python versions are available for installation using this command:
conda search "^python$"
This command will list all the available Python versions you can use to create your environment.
Step 5: Create a New Virtual Environment
Now let’s create a new environment. You can choose any name for your environment (for example, myenv) and specify the Python version.
conda create -n myenv python=3.9 anaconda
Here:
- -n myenv is the name of your environment.
- python=3.9 sets the version of Python.
- anaconda installs all common data science libraries.

Press y when it asks for confirmation.

Step 6: Check the List of Environments
To see all the environments you have created, type:
conda info -e
or:
conda env list
This will show the list of environments along with their paths.
Step 7: Activate the Virtual Environment
To start using your new environment, activate it with this command:
conda activate myenv
Once activated, your prompt will show the environment name at the beginning, like this: (myenv) C:\Users\YourName>

Step 8: Install Packages in the Environment
You can now install any Python packages you need. For example, to install NumPy and Pandas, type:
conda install numpy pandas
If a package is not available in conda, you can use pip:
pip install package_name

Step 9: Check Installed Packages and Python Version
To check which Python version your environment is using:
python --version

To view the list of installed packages:
conda list

Step 10: Deactivate the Virtual Environment
When you finish your work and want to go back to the base environment, type:
conda deactivate

This will return you to the main conda environment.
Step 11: Delete a Virtual Environment
If you no longer need an environment, you can remove it completely using this command:
conda remove -n myenv --all
Replace myenv with your environment name. Type y when asked for confirmation.
