Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clone a conda environment from one python release to another?

Tags:

python

conda

I have a python 2.7 conda environment and would like to create an equivalent environment with python 3.4. I am aware of the --clone option when creating environments, but it won't accept additional arguments, like python=3.4. Is there a way to do this automatically? I thought about trying to use the output from conda list --export, but that also encodes the python release.

like image 990
godber Avatar asked Jul 09 '14 21:07

godber


1 Answers

One way would be to

conda list --export > exported-packages.txt 

And then edit that file to remove the last part of each package with the py27_0 parts (you might also want to remove the versions, in case some version of a package doesn't have a Python 3 version). Then

conda create -n py3clone --file exported-packages.txt 

Another idea would be to clone the environment:

conda create -n clonedenv --clone oldenv conda install -n clonedenv python=3.4 conda update -n clonedenv --all 

Note that obviously both of these will fail if you have some package that doesn't have a Python 3 version.

like image 176
asmeurer Avatar answered Sep 23 '22 02:09

asmeurer