Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove unwanted python packages from the Base environment in Anaconda

Tags:

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.

like image 416
Ind Avatar asked Feb 10 '19 15:02

Ind


People also ask

How do I remove unused packages from a conda environment?

"conda clean --all --dry-run" is listing unused packages as well. (mycondaenv) C:\myrepo>conda clean --packages --dry-run Will remove 685 (9.45 GB) package(s).

How do I remove a package from environment?

From the R terminal enter the command remove. packages("package-to-remove") to remove or uninstall the package from R environment.

Does removing conda environment remove all packages?

Remove a list of packages from a specified conda environment. This command will also remove any package that depends on any of the specified packages as well---unless a replacement can be found without that dependency.


2 Answers

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

like image 148
Juan Leni Avatar answered Oct 04 '22 03:10

Juan Leni


conda remove <package_name>

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

like image 31
Joe Tilsed Avatar answered Oct 04 '22 03:10

Joe Tilsed