Andrea Ianni
Andrea Ianni

Reputation: 839

Conda environment lost

I had a previous installation of Python 2.7 and I still have all the related packages in C:\Program Files\Anaconda. enter image description here

Some days ago I was not able to do conda update conda because there was a problem with the repositories. I solved that issue just installing miniconda. What I did not want is to overwrite my environment:

enter image description here

What should I do? Creating another environment and making it pointing to C:\Program Files\Anaconda? How can I do that?

Upvotes: 3

Views: 9062

Answers (2)

holdenweb
holdenweb

Reputation: 37103

I offer this comment in the hopes it might assist any future reader wishing to avoid the same predicament.

Conda environments can be completely re-created from the rather small output of the conda env export command. Such outputs are often named environment.yaml, though this is merely a convention. I just created (with the command conda create --name empty python=3.7) a new environment. This is what conda env export --name empty spits out.

name: empty
channels:
  - http://conda.anaconda.org/holdenweb
  - anaconda-fusion
  - defaults
dependencies:
  - ca-certificates=2018.03.07=0
  - certifi=2018.8.24=py37_1
  - libcxx=4.0.1=h579ed51_0
  - libcxxabi=4.0.1=hebd6815_0
  - libedit=3.1.20170329=hb402a30_2
  - libffi=3.2.1=h475c297_4
  - ncurses=6.1=h0a44026_0
  - openssl=1.0.2p=h1de35cc_0
  - pip=10.0.1=py37_0
  - python=3.7.0=hc167b69_0
  - readline=7.0=h1de35cc_5
  - setuptools=40.2.0=py37_0
  - sqlite=3.24.0=ha441bb4_0
  - tk=8.6.8=ha441bb4_0
  - wheel=0.31.1=py37_0
  - xz=5.2.4=h1de35cc_4
  - zlib=1.2.11=hf3cbc9b_2
prefix: /usr/local/anaconda3/envs/empty

By saving this YAML file (perhaps in a Github repository or somewhere else safe from clumsy fingers) you can re-create the environment at any time with the commmand

conda env create -f path/to/YAML/file -n empty_copy

Exchanging YAML files is also a simple way to ensure that all members of a team are using equivalent environments. Exporting conda environments deals reasonably well with pip-installed packages, but there are some rough edges so stick to simple requirement specifications.

I apologise to the original questioner, for whom I understand this advice comes far too late. I presume because the answer was accepted the problem was solved!

Upvotes: 4

Styrke
Styrke

Reputation: 2664

As far as I know, Miniconda and Anaconda are mostly the same thing with different default packages when you create new environments.

Your old Anaconda environments should still be available in C:\Users\[username]\Anaconda\envs, so try copying them from there to your new Miniconda installation's envs-folder in C:\Users\[username]\Miniconda2\envs and see if they show up when you write conda info --envs.

Upvotes: 3

Related Questions