5

I am using Anaconda. I would like to know how to remove or uninstall unwanted packages from the base environment. I am using another environment for my coding purpose.

I tried to update my environment by using yml file (Not base environment). Unexpectedly some packages installed by yml into the base environment. So now it has 200 python packages which have another environment also. I want to clear unwanted packages in the base environment and I am not using any packages in the base environment. Also, my memory is full because of this.

Please give me a solution to remove unwanted packages in the base environment in anaconda.

It is very hard to remove one by one each package, therefore, I am looking for a better solution.

Juan Leni
  • 6,982
  • 5
  • 55
  • 87
Ind
  • 377
  • 2
  • 6
  • 16
  • 1
    You sound like you want MiniConda. There isn't much point installing the full Anaconda environment and then removing packages, if you want a blank slate to build on – roganjosh Feb 10 '19 at 15:19
  • 1
    Possible duplicate of [conda: remove all installed packages from base/root environment](https://stackoverflow.com/questions/52830307/conda-remove-all-installed-packages-from-base-root-environment) – Ashwin Geet D'Sa Feb 10 '19 at 15:21
  • 6
    I feel like no one is addressing the OPs *real* question: if you code a decent amount, every now and again, you will accidentally `pip install` or `conda install` in your base environment. But it is hard to know what packages are in the base environment because they are part of core functionality, and what ones are there because of accidental installs, say, 2 weeks ago when you were in a rush and made a mistake. @Ind, if this is your real question, I would like to update your question to reflect this. – Mike Williamson Dec 01 '20 at 08:54

3 Answers3

5

It is the same as for other environments:

  • run conda deactivate to be sure you are in the base environment.
  • run conda list to see the packages that you have installed
  • run conda remove {package_name} to remove packages

Update:

WARNING: Be careful because there are bugs around this new functionality https://github.com/conda/conda/issues/6316

I have not tested it myself, so try at your own risk

To reset your base environment you should:

  • conda list --revisions

This will show you a list of revisions. At this moment, the latest is:

2019-02-11 21:58:57 (rev 19)

 conda  {4.6.2 -> 4.6.3}

Now run, where 19 can be replaced for the revision you want to use:

  • conda install --rev 19

If you use:

  • conda install --rev 1

Then it should reset the base environment to how it looked like when you installed anaconda.

Reference: https://github.com/conda/conda/issues/1032

According to the tickets, if you are not using conda 4.4 release or upwards, you may end up removing conda too because of this bug: https://github.com/conda/conda/issues/6316

Juan Leni
  • 6,982
  • 5
  • 55
  • 87
  • 2
    how to find unwanted packages. I do not need any packages in base environment but I think it should have some packages. So i want remove unwanted packages – Ind Feb 10 '19 at 15:15
  • 3
    'unwanted' is not very well defined... Can you define an 'unwanted' package? – Juan Leni Feb 10 '19 at 16:17
  • Unwanted means keep default packages and remove user installed packages – Ind Feb 16 '19 at 01:41
  • 1
    I have updated the answer for the use case you are describing – Juan Leni Feb 16 '19 at 09:21
  • After accidentally installing packages in `base` instead of another environment, I had good luck (so far..) with running `conda install --rev [latest-revision-number-minus-1]` in the `base` environment. – lab Jun 30 '21 at 11:42
1
conda remove <package_name>

More info can be found: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#removing-packages

Joe Tilsed
  • 324
  • 2
  • 13
0

Please use the below code: conda uninstall -n base <Package_name>

Ashwin Geet D'Sa
  • 6,346
  • 2
  • 31
  • 59