180

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?

chrisaycock
  • 36,470
  • 14
  • 88
  • 125

3 Answers3

194

I had to use the install function instead:

conda install pandas=0.13.1
chrisaycock
  • 36,470
  • 14
  • 88
  • 125
  • 21
    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. – mrgloom Sep 23 '18 at 20:43
  • @mrgloom `conda remove` also updates some packages I don't want to be updated. – Shahrokh Bah Feb 20 '21 at 09:05
  • 4
    @mrgloom plain `install pkg=1.2.3` works for me in 2022 for downgrading: https://gist.github.com/maphew/273b5c5af1c11664724ecdeafd52ddca. It did take a long time for the "Solving environment" stage though. – matt wilkie Jan 25 '22 at 18:53
175

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
anon01
  • 10,618
  • 8
  • 35
  • 58
  • 7
    This should be the correct answer as it should roll back updated dependencies as well – Ian Jul 28 '17 at 14:46
  • 6
    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 [issue](https://github.com/conda/conda/issues/5435) – Fridolin Linder Sep 07 '17 at 15:47
  • 5
    This is buggy. Doesn't work. I lost my packages including numpy. – Binu Jasim Sep 14 '17 at 07:41
  • 1
    If you loose your packages you can simply reinstall the revision that contains the package in question... this is actually quite nice – zelusp Jan 04 '18 at 20:09
  • 1
    @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? – Rebel Aug 11 '18 at 02:16
  • 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 useful – Notso Oct 29 '18 at 09:58
  • 3
    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. – Willower Nov 21 '18 at 15:22
  • Also this seems like it rollback everything. The first answer shows how to downgrade a "package" like the question asks for. – user14492 Mar 19 '19 at 13:06
  • 3
    @FridolinLinder now the open issue has been closed – Pradeep Singh Feb 17 '20 at 12:02
  • I think this does not show packages installed with `pip`, only shows revisions of packages installed with `conda` – user88484 Jan 01 '23 at 09:52
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.

szelesaron
  • 59
  • 7