How to uninstall all unused packages in a conda virtual environment?

前端 未结 2 481
天涯浪人
天涯浪人 2020-12-24 12:33

I have a conda virtual environment with several unused packages installed inside it (either using pip install or conda install).

What is th

相关标签:
2条回答
  • 2020-12-24 13:17

    @AgileBean I try an answer to your comment's question on why --packages gives you more results than --all. This is still related to the main question how to uninstall, hopefully.

    The difference between

        conda clean --yes --all
    

    and

        conda clean --yes --packages
    

    is that the packages are only the extracted folders. All of the other files (.tar.bz2, .conda, that is: tarballs) are not cleaned by --packages.

    If you want to clean only the tarballs, you would need

        conda clean --yes --tarballs
    

    References: Anaconda Python: Delete .tar.gz in pkgs

    Here is an example of the differences. Mind that --all includes --packages in a real run, but it does not show --packages results in dry-run (very strange!, see the following screenshot, it just stops at DryRunExit: Dry run. Exiting.)

    Which differences exist that could explain that you find more with --packages than with --all?

    1. As said before, my first guess is that you only used dry-run option which will not show you the cleaned --packages when you run conda clean --all --dry-run. Therefore see this real run from conda clean --all:

    2. The 2 warnings could be interesting:

      WARNING: C:\Users\Admin\.conda\pkgs does not exist                                                                                                                                           
      WARNING: C:\Users\Admin\AppData\Local\conda\conda\pkgs does not exist
      

      But if you do not dry-run, but really run --all, you get the same, because --all includes the --packages and thus its warnings as well. This, again, cannot be seen when you use dry-run.

    3. A good reason could be that you have once cleaned your packages with --tarballs or that you have simply removed some tarballs manually so that your unzipped packages outnumber your tarballs in the --dry-run.

    4. You might have unzipped a lot of packages manually into the cache folder, e.g. the manual installations from git and all of the other installations that do not offer conda / pip install and then again, in --dry-run, the --all exits without showing the --packages.

    5. Perhaps you find another thing in the docs? https://docs.conda.io/projects/conda/en/latest/commands/clean.html. It says about symbolic links: "WARNING: This does not check for packages installed using symlinks back to the package cache." As --packages is part of --all, this is still no explanation of your difference.

    I guess that the reason for your --packages > --all issue is that conda clean --all --dry-run does not show the results of the --packages, although it cleans them as well, so that you do not actually have that issue ;).

    0 讨论(0)
  • 2020-12-24 13:23
    conda clean --yes --all
    

    will sanitize everything. But take note: if you ever want to do any type of --offline operations, don't use --all; be more selective.

    0 讨论(0)
提交回复
热议问题