Create Environments with Different Python Versions in Anaconda

visibility 174 access_time 5 months ago languageEnglish timeline Stats
timeline Stats
Page index 1.17

With Anaconda, we can create virtual environments with different Python versions. This can be very handy when certain package only supports certain Python versions.

This article shows you the simple guide of creating different environments.

Install Anaconda

You can install the individual edition from this website: https://www.anaconda.com/products/individual.


Once installed, open CMD.exe Prompt from the navigator. 

Create virtual environments

The following commands create three environments with different Python versions:

conda create -n py37 python=3.7
conda create -n py38 python=3.8
conda create -n py39 python=3.9

The above command lines create three environments named py37, py38 and py39 with python versions 3.7, 3.8 and 3.9 respectively.

Activate environments

You can use conda activate $environment_name to activate environments.

conda activate py37

The above command line activate virtual environment named py37.

Deactivate environments

To deactivate, simply run the following command and Anaconda Prompt will switch back to the default environment:

conda deactivate

Install packages

Install package using the following command line:

conda install package_name

You can also install pip in the environment and then use pip to install packages. 

copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

More from Kontext
Create and Read Pickle Files in Python
visibility 3,441
thumb_up 0
access_time 2 years ago
Convert String to Date using Python
visibility 2,551
thumb_up 0
access_time 3 years ago