Changing the Python Version in Conda

Ben Cook • Posted 2017-03-09 • Last updated 2021-10-15

The latest version of Anaconda comes with Python 3.8. But sometimes you need to use an earlier release. With Anaconda, the preferred way to use a previous version of Python is to create a separate conda environment for each project.

For example, to create a fresh conda environment called my-cool-project with Python 3.7 and its own pip, run the following:

conda create --name my-cool-project python=3.7 pip

If you want a different version, like Python 3.6, just swap in python=3.6. From there you can activate the my-cool-project environment and then pip install or conda install whatever you need. For example:

conda activate my-cool-project
pip install tensorflow

Then, to return to the base environment, just run:

conda deactivate

If possible, use the above approach to manage different versions of Python on your machine. However, if you really need to, you can change the base version of Python with a one-liner:

conda install python=3.7

If you confirm that you want to proceed, conda will replace all the version 3.8 packages (including the Python interpreter) in your environment with the corresponding 3.7 versions.