How to downgrade or upgrade python versions in Anaconda distribution

Feng Li
2 min readSep 21, 2021

--

Changing package versions in an Anaconda distribution is not as easy as you thought or told by many online resources. Most likely you’ll get caught by conda figuring package plan which ends up hanging or failed with conflicts eventually — if just run “conda install”.

Actually you need to do this using Anaconda metapackage which should be the official way.

Anaconda provides metapackage called “anaconda”. Anaconda distribution installer has been built with specified python version using this metapackage for you to download. More about metapackage.

Anaconda metapackage supports multiple python versions. This can be found in release notes. For example, in Anaconda distribution 2021.05 release notes.

“Meta-packages are available for Python 3.7, 3.8 and 3.9. The installer uses Python 3.8.”

This means Anaconda 2021.05 distribution installer will install python 3.8 by default but there is a way you can use python 3.7 or 3.9.

But how to do it?

In following example, I’ll use Anaconda 2020.07 as it’s handy. Similarly it’s supporting multiple python versions with 3.8.3 in the installer. I’ll downgrade python to 3.7.9 to meet my needs.

Step 1, Go to Anaconda 2020.07 installation path and take a look at metapackage “anaconda”.

[feng@plum1 anaconda]$ pwd
/anacondadeploy/anaconda202007/anaconda
[feng@plum1 anaconda]$ ./bin/conda list | grep anaconda
anaconda 2020.07 py38_0

we can also search “python” to find supported versions.

[feng@plum1 anaconda]$ ./bin/conda search python
python 3.7.9 h7579374_0 pkgs/main
python 3.8.3 hcff3b4d_2 pkgs/main
python 3.9.4 hdb3f193_0 pkgs/main

Step 2, Create conda env specifying python version along with metapackage “anaconda”.

[feng@plum1 anaconda]$ ./bin/conda create -n py379anaconda202007 python=3.7.9 anaconda=2020.07

Step 3, then, you can export this env to a yaml file to distribute it.

[feng@plum1 anaconda]$ ./bin/conda env export — name py379anaconda202007 > /tmp/py379anaconda202007.yml

Happy Reading!

--

--

Feng Li

Software Engineer, playing with Snowflake, AWS and Azure. Snowflake Data Superhero 2024. SnowPro SME, Jogger, Hiker. LinkedIn: https://www.linkedin.com/in/fli01