How do I revert to a previous package in Anaconda?
Asked Answered
G

4

185

If I do

conda info pandas

I can see all of the packages available.

I updated my pandas to the latest this morning, but I need to revert to a prior version now. I tried

conda update pandas 0.13.1

but that didn't work. How do I specify which version to use?

Gnosis answered 31/5, 2014 at 20:10 Comment(0)
G
198

I had to use the install function instead:

conda install pandas=0.13.1
Gnosis answered 31/5, 2014 at 20:16 Comment(3)
Seems this is not working when you have already installed package, so it's not downgrading, it's just fresh install of specific version. So you need to uninstall old version and install new specific version.Gonzales
@Gonzales conda remove also updates some packages I don't want to be updated.Cauvery
@Gonzales plain install pkg=1.2.3 works for me in 2022 for downgrading: gist.github.com/maphew/273b5c5af1c11664724ecdeafd52ddca. It did take a long time for the "Solving environment" stage though.Severally
E
177

For the case that you wish to revert a recently installed package that made several changes to dependencies (such as tensorflow), you can "roll back" to an earlier installation state via the following method:

conda list --revisions
conda install --revision [revision number]

The first command shows previous installation revisions (with dependencies) and the second reverts to whichever revision number you specify.

Note that if you wish to (re)install a later revision, you may have to sequentially reinstall all intermediate versions. If you had been at revision 23, reinstalled revision 20 and wish to return, you may have to run each:

conda install --revision 21
conda install --revision 22
conda install --revision 23
Elephant answered 20/2, 2016 at 17:43 Comment(11)
This should be the correct answer as it should roll back updated dependencies as wellFoldaway
Note that this solution can currently lead to conda itself being removed. I ended up having to reinstall anaconda from scratch after trying this. Seems to be an open issueClod
This is buggy. Doesn't work. I lost my packages including numpy.Gonzalogoo
If you loose your packages you can simply reinstall the revision that contains the package in question... this is actually quite niceConley
@anon01, I tried this on my Ubuntu but I got this "CondaRevisionError: Cannot revert to 26, since astropy::iminuit-1.2-py36_0 is not in repodata." Is there any way to debug it?Careworn
This doesn't help if you need to revert to a specific version of a package that you may never have had installed. The accepted answer is more usefulDiaphanous
This worked for me. My problem occurred when i installed tensorflow which made loads of changes to my environment. Next time, as a best practice, i advice people(myself included) to create a new environment for any new package that wants to make changes to existing ones so concerns are separated.Paganize
Also this seems like it rollback everything. The first answer shows how to downgrade a "package" like the question asks for.Preconcerted
@FridolinLinder now the open issue has been closedEmbryectomy
I think this does not show packages installed with pip, only shows revisions of packages installed with condaKenaz
Did the command syntax change? Conda page shows using an equals sign: "To restore environment to a previous revision: conda install --revision=REVNUM or conda install --rev REVNUM."Fungoid
C
2

I know it was not available at the time, but now you could also use Anaconda navigator to install a specific version of packages in the environments tab.

Chishima answered 3/1, 2021 at 11:12 Comment(0)
M
0

You can do this in 2 ways.

1. Remove previous version and Freshly install desired version

conda remove <package_name>

Search for your package version whether it is available in conda repository.

conda search <package_name>

If it is available in the list;

conda install <package_name>=<version>

If you are going for a newer version, it may not be available. Then go for pip install <package_name> pip packages work fine with Anaconda distribution but they encourage using conda.


2. Install by downgrading package Search for package availability

conda search <package_name>

conda install <package_name>=<version>

It may ask you to downgrade some dependencies. (optional) Type y and hit enter.

Minsk answered 12/4 at 20:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.