Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Python version of existing conda virtual environment?

I created a conda environment with Python version 3.8, but it doesn't support matplotlib... So I am looking for something like this to change the Python version: conda env my_env update to python=3.6. Is this possible or do I need to recreate the environment?

I have miniconda installed.

like image 1000
elixirtrip Avatar asked Dec 03 '19 18:12

elixirtrip


People also ask

How do I change the python version in conda base environment?

Anaconda uses a default environment named base and you cannot create a new (e.g. python 3.6) environment with the same name. This is intentional. If you want your base Anaconda to be python 3.6, the right way to do this is to install Anaconda for python 3.6.

How do I install python 3.7 in anaconda environment?

This can be installed via conda with the command conda install -c anaconda python=3.7 as per https://anaconda.org/anaconda/python. Though not all packages support 3.7 yet, running conda update --all may resolve some dependency failures.


2 Answers

Activate the relevant environment, then install your target python version.

conda activate my_env
conda install python=3.6
like image 181
Alexander Avatar answered Oct 07 '22 14:10

Alexander


Adding to the answer above

conda activate my_env
conda uninstall python
conda install python=x.x
like image 17
jacktim Avatar answered Oct 07 '22 13:10

jacktim