elixirtrip
elixirtrip

Reputation: 2023

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.

Upvotes: 192

Views: 311906

Answers (7)

Steve
Steve

Reputation: 1

I needed to create a copy of my current python 3.11 environment but with python 3.10.

trying

conda install python=3.10

resulted in conda telling me that it couldn't figure stuff out because python_abi and thing dependent on it were the problem.

So...

steps needed:

conda create --name py-3.10 --clone py-3.11
conda activate py-3.10
conda remove python_abi  <--- this was the blocker stopping me
conda install python=3.10
conda install python_abi keyboard levenshtein

When I removed python_abi it warned me that the packages keyboard and levenshtein would be removed, so the last step that adds the python_abi back had to add these back too.

It's better than having to reload ALL of your packages

Upvotes: 0

Paribesh Neupane
Paribesh Neupane

Reputation: 1

If you tried which python and pulled your hair every time you saw the same version, try command which python3 instead of which python. That did the trick.

Upvotes: -2

Omolayo Ipinsanmi
Omolayo Ipinsanmi

Reputation: 1

I solved this by putting the python in quotes like "python= 3.10"

Upvotes: 0

Gray Programmerz
Gray Programmerz

Reputation: 609

If you already have existing python installation may be in other environment, you can simply use it as base.

Here's what you need to do:

conda activate base
conda install python=3.6

Note: This will activate root environment. and python 3.6 already installed, it will simply replace it.

Upvotes: 4

jacktim
jacktim

Reputation: 632

Adding to the answer above

conda activate my_env
conda uninstall python
conda install python=x.x

Upvotes: 43

Zhang Jian
Zhang Jian

Reputation: 173

Rebuild a new environment, for example called "myenvi"

conda create --name myenvi python=3.6

And make sure the version by

python --version

After installing all packages, double-check with

conda list -n myenvi

Upvotes: 9

Alexander
Alexander

Reputation: 109726

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

conda activate my_env
conda install python=3.6

Upvotes: 315

Related Questions