What does the –all flag do for conda env remove?

Question:

I would like to delete an Anaconda environment. From this reference, it looks like I could use

conda remove --name myenv --all

or

conda env remove --name myenv

The documentation (for 4.6.0) mentions both, but does not explain the difference.

How might I determine what the --all flag does?

Asked By: mherzog

||

Answers:

There is no difference in effect.

Conda has two remove commands:

  • conda remove – for removing packages
  • conda env remove – for removing environments

Both have a --name,-n argument that specifies the environment on which to operate. Only the former also has an --all flag, which effectively does the same thing as the latter.1


Obsolete (From Original Answer)

The original first example in the question had a typo and was invalid because it indicated to remove package(s) from an environment, but did not specify any packages. Running it would have yielded an error message:

$ conda remove -n myenv

CondaValueError: no package names supplied,
       try "conda remove -h" for more details

[1] This is a slightly inconsistent API design, in my opinion. Since one can create an empty environment, I believe a more symmetric result of conda remove --all would be that it remove all the packages but still retain the empty environment. Users that want to operate on a whole environment level should being using conda env commands. Unfortunately, this overlap of functionality is an artifact of ontogeny, namely, conda-env was originally a separate package that came after conda, and so conda remove -n envname --all was the original idiom for environment removal.

Answered By: merv

conda env has been deprecated, see conda -h output. The documentation now only mentions conda remove --all -n myenv to remove an environment.

$ conda -V
22.11.1

$ conda -h 
usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    clean             Remove unused packages and caches.
    compare           Compare packages between conda environments.
    config            Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file (/Users/corneliusromer/.condarc) by default. Use the --show-
                      sources flag to display all identified configuration locations on your computer.
    create            Create a new conda environment from a list of specified packages.
    info              Display information about current conda install.
    init              Initialize conda for shell interaction.
    install           Installs a list of packages into a specified conda environment.
    list              List installed packages in a conda environment.
    package           Low-level conda package utility. (EXPERIMENTAL)
    remove (uninstall)
                      Remove a list of packages from a specified conda environment.
    rename            Renames an existing environment.
    run               Run an executable in a conda environment.
    search            Search for packages and display associated information.The input is a MatchSpec, a query language for conda packages. See examples below.
    update (upgrade)  Updates conda packages to the latest compatible version.
    notices           Retrieves latest channel notifications.

options:
  -h, --help          Show this help message and exit.
  -V, --version       Show the conda version number and exit.

conda commands available from other packages (legacy):
  env

Note the "(legacy)" in "conda commands available from other packages (legacy)".

Answered By: Cornelius Roemer
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.