Reputation: 1108
Given the pending retirement of python 2 support in January 2020, we should be thinking about migrating from Miniconda2, which is python 2 based, to Miniconda3, which is python 3 based.
As of the date of asking this question, the Miniconda web pages don't address this topic.
Is there a good procedure for converting from Miniconda2 to Miniconda3 that will preserve the existing environments created under Miniconda2?
Upvotes: 1
Views: 1995
Reputation: 156
If you're as late as me porting from miniconda2 to miniconda3... it seems you don't have to worry about losing any envs. When installing miniconda3 (into a different path than miniconda2) it found and listed all of the environments installed in my miniconda2 directory. This allowed me to clone envs into the miniconda3 directory with conda create --clone <path-to-miniconda2-env> - <new-env-name>
before clearing up miniconda2, rather than relying on yml files which sometimes need alteration (although I would still recommend saving yml configs of your envs before installing miniconda3).
Upvotes: 0
Reputation: 8279
You could try to upgrade your python version as suggested in this answer:
conda install python=3.7
But I'm not sure how safe that would be. (unsafe)
A safe approach is to simply install miniconda3 into a new path on your machine reproduce identically your current environments on the new miniconda installation.
To do that, you'll have to create a spec list for each of your environments in miniconda2 by:
conda activate myenv
conda list --explicit > myenv-spec-file.txt
Then under your miniconda3 installation, do:
conda create --name myenv --file myenv-spec-file.txt
The conda
docs have detailed instructions on this process.
Keep in mind that when you install miniconda3, it will add an entry into your .*rc
file (e.g. .bashrc
, if using bash) and the new conda based on python 3 will be used when running any conda
command. So you should create your spec files prior to installing miniconda3.
Edit: As pointed out by merv and nekomatic, upgrading conda in-place is not safe.
Upvotes: 2