conda commands for Anaconda and Navigator

Anaconda's documentation for Navigator lists no keyboard shortcuts, and the program itself binds only a handful of window keys, shown in the last table. Navigator is a graphical front end for conda, so this page is mainly a reference to the conda commands behind its buttons, taken from the conda 26.9.1 documentation: environments, packages, channels, configuration and cleanup. Words in capitals such as ENVNAME are placeholders, and most commands act on the active environment unless a name is given.

93 commands in 9 sections. Checked row by row against conda 26.9.1 documentation on . Edited by Jay.

Creating and activating environments 14

Navigator does this environment, package and channel work through its own windows: Anaconda describes it as a graphical way to manage them without typing commands.

CommandWhat it does
conda create --name ENVNAMECreate an environmentMakes a new environment under that name; package specs added after it are installed straight away.
conda create --name ENVNAME python=3.10Create with a chosen PythonPins the interpreter version at the moment the environment is built.
conda create -n myenv python=3.12 numpyCreate with packagesUses the short -n flag and installs every listed spec while the environment is being made.
conda activate ENVNAMEActivate an environmentSwitches the current shell to that environment, so later installs land in it.
conda activateSwitch back to default environmentWith no name it goes to the default environment, which the guide prefers over deactivating.
conda deactivateDeactivate current environmentLeaves the active environment; run from base, it can leave the shell unable to find conda.
conda info --envsList environments and pathsThe environment marked with an asterisk is the active one.
conda env listList all environmentsPrints the same list as the info command with --envs.
conda create --clone ENVNAME --name NEWENVClone an environmentBuilds NEWENV as a copy of an environment that already exists on this machine.
conda rename --name ENVNAME NEWENVNAMERename an environmentTakes the present name after --name and the replacement as the last argument.
conda remove --name ENVNAME --allDelete an environmentThe --all flag removes every package and then the environment itself.
conda env remove --name myenvDelete with env removeSecond way to delete an environment, offered by the guide beside conda remove with --all.
conda remove -n myenv --all --keep-envEmpty an environmentUninstalls everything inside it but leaves the environment in place.
conda run -n my-python-env python --versionRun a program in an environmentExecutes one command inside the named environment, an alternative to activating it first.

Environment history and variables 5

CommandWhat it does
conda list --name ENVNAME --revisionsList environment revisionsShows the numbered history of changes that a rollback can point to.
conda install --name ENVNAME --revision NUMBERRoll back to a revisionReturns the environment to the state saved under that number.
conda env config vars set my_var=valueSet an environment variableThe variable only takes effect after the environment has been activated again.
conda env config vars listList environment variablesPrints what is stored with the environment; the same values are kept when it is exported.
conda env config vars unset my_var -n test-envUnset an environment variableDeletes the stored value from the environment named after -n.

Exporting and recreating environments 13

conda env export is the older command and writes YAML only; conda export is the one that offers the JSON, explicit and requirements formats.

CommandWhat it does
conda export --format=environment-yamlExport as YAMLWrites an environment spec that the cheat sheet marks as usable on other platforms.
conda export --format=environment-jsonExport as JSONThe same portable spec, written in JSON syntax.
conda export --from-historyExport only requested specsBuilds the spec from the packages that were explicitly requested, as recorded in the environment history.
conda export --format=explicitExport an explicit listThe result is tied to one platform and to exact package builds.
conda export --format=requirementsExport a requirements listPlatform and package specific like the explicit format, in requirements form.
conda export --file=environment.yamlExport to a named fileThe output format is detected from the name of the file.
conda env export > environment.ymlExport with the older commandYAML only; the file covers pip packages as well as conda ones.
conda create --file ENV.ymlCreate from a YAML fileThe new environment takes its name from the file's first line.
conda create --name ENVNAME --file ENV.txtCreate from a text fileBuilds a named environment out of a package list saved as text.
conda env create -f /path/to/environment.ymlCreate from a definition fileThe spec is solved when it is installed; -f is needed whenever the file sits in another directory.
conda env update --pruneSync environment with its fileApplies environment.yml again and uninstalls whatever the file has stopped listing.
conda list --explicitList packages with their URLsPrints a spec list that create --file can rebuild from on the same platform.
conda list --export > package-list.txtSave the package listStores requirement strings in a file that create --file can read back.

Installing and updating packages 15

CommandWhat it does
conda install scipyInstall a packageWith no -n or -p flag the package goes into whichever environment is active.
conda install --name ENVNAME PKGNAME1 PKGNAME2Install into a named environmentSeveral package names can follow, and the target need not be active.
conda install PKGNAME=3.1.4Install a specific versionAn equals sign after the name fixes the version to fetch.
conda install "PKGNAME>2.5, <3.2"Install within a version rangeThe comma means AND, so the version has to satisfy both limits.
conda install "PKGNAME [version='2.5|3.2']"Install one of two versionsThe vertical bar means OR, so either listed version is accepted.
conda install PKGNAME1 PKGNAME2 --yesInstall without the promptAnswers the confirmation question automatically; the flag works on other conda commands too.
conda install pipAdd pip to the environmentPuts pip inside the active environment, so what it installs shows up in conda list.
conda update --allUpdate all packagesWorks on the active environment unless a name is added.
conda update --all --name ENVNAMEUpdate a named environmentConfines the update to that environment, whichever one is active.
conda update biopythonUpdate one packageConda reports what would change and lets you decide before anything is installed.
conda update pythonUpdate PythonStays within the current series: a 3.x interpreter moves to the highest 3.x release available.
conda update --name base condaUpdate conda itselfTargets the base environment, where the conda program is installed.
conda uninstall PKGNAMEUninstall a packageTakes the package out of the environment that is active.
conda uninstall --name ENVNAME PKGNAMEUninstall from a named environment
conda remove -n myenv scipy curl wheelRemove several packagesAnything that depends on them goes too, unless conda finds a replacement without that dependency.

Listing and searching packages 8

CommandWhat it does
conda listList installed packagesCovers the active environment and includes packages that pip installed there.
conda list --name ENVNAME --show-channel-urlsList packages of another environmentNames the environment to inspect and adds the channel each package came from.
conda list ^pyFilter the list by regexShows only names matching the regular expression, here those starting with py.
conda list --fields name,versionChoose the list columnsPrints just the fields given, separated by commas.
conda search scikit-learnSearch for a package
conda search PKGNAME --infoShow package detailsAdds detailed records for every match, including the dependencies each build requires.
conda search 'numpy>=1.12'Search by versionThe query is a MatchSpec, so a version condition can follow the name.
conda search numpy[subdir=linux-64]Search another platformWithout the subdir part, only builds for the current platform appear.

Channels 13

CommandWhat it does
conda config --show channelsShow configured channelsLists the channels conda is set to use at the moment.
conda config --show-sourcesShow configuration sourcesDisplays each configuration file conda identified, which is where channel lists come from.
conda config --add channels CHANNELNAMEAdd a channel at the topThe new channel goes first in the list and so gets the highest priority.
conda config --prepend channels new_channelPrepend a channelEquivalent to --add: the channel is placed first.
conda config --append channels new_channelAppend a channelPuts the channel last, which gives it the lowest priority.
conda config --remove channels defaultsRemove the defaults channelAdd another channel first: conda errors when the only configured channel is taken away.
conda config --set channel_priority strictTurn on strict channel priorityAdvised only when channels have to be mixed; some environments may then fail to solve.
conda config --set channel_priority disabledTurn off channel priorityConda then takes the newest version of a package from any listed channel.
conda install --channel CHANNELNAME PKGNAMEInstall from a channelSearches that channel first for this one command, ahead of the channels already configured.
conda install CHANNELNAME::PKGNAMEInstall one package from a channelOnly that package comes from the channel; dependencies resolve from the configured ones.
conda install --channel conda-forge --override-channels numpyInstall from one channel onlyIgnores every channel configured in .condarc for the duration of the command.
conda search conda-forge::numpySearch one channel
conda list --show-channel-urlsShow where packages came fromAdds the source channel of every installed package to the listing.

Configuration and shell setup 9

CommandWhat it does
conda config --showShow configuration valuesPrints all settings as conda has worked them out from every source.
conda config --describe channel_priorityDescribe a settingPrints the built-in explanation of the option that is named.
conda config --set verbosity 3 --envSet a value for one environmentWith --env the value is written to the .condarc of the active environment, not the user file.
conda config --remove-key KEYDelete a configuration keyTakes the key out together with every value stored under it.
conda config --add create_default_packages PACKAGENAME1 PACKAGENAME2Set default packagesFrom then on the named packages are installed into each environment you create.
conda config --set notify_outdated_conda falseSilence the update warningStops the message that tells you a newer conda is available.
conda initSet up shell integrationMost shells have to be closed and reopened before the change applies.
conda init --reverseUndo the shell setupReverts what the most recent init run changed.
conda init --condabinPut only condabin on PATHLeaves the shell function out, so just the conda executable becomes reachable.

Information, health checks and cleanup 10

CommandWhat it does
conda infoShow installation detailsPrints version and setup details, which also confirms that conda is installed.
conda --versionShow the conda versionConda answers with the version number that is installed.
conda COMMAND --helpGet help for a commandReplace COMMAND with a subcommand such as create or install to see its options.
conda doctorCheck environment healthRuns the registered health checks; the same report is available under the name conda check.
conda doctor --listList the health checksShows every check that exists and whether a fix is attached to it.
conda doctor --fixRepair detected problemsAsks for confirmation before changing anything unless --yes is added.
conda clean --allClear caches and unused filesDeletes the index cache, unused cached packages, tarballs, temporary files and log files.
conda clean --index-cacheClear the index cache
conda clean --packagesRemove unused cached packagesEnvironments that conda info --envs does not list are not checked for links into the cache.
conda clean --tarballsRemove cached tarballs

Notes

Navigator is a front end for conda

Anaconda Navigator is the desktop window over the conda engine: Anaconda describes it as a way to launch applications and manage packages, environments and channels without typing commands. Its documentation has no shortcut list, and the Navigator 2.7.2 source binds only a few keys: Ctrl + P opens Preferences, Ctrl + R restarts Navigator, Ctrl + Q quits, F6 opens the logs viewer and F11 toggles full screen. Creating environments, installing packages and launching applications have no keys; in Navigator they are buttons, and in a terminal they are the commands on this page.

The commands worth learning first

Three commands cover most sessions: conda create --name ENVNAME makes an environment, conda activate ENVNAME switches the shell into it, and conda install scipy adds a package to whichever environment is active. To move a working setup to another machine, write it to a file with conda export --file=environment.yaml and rebuild it there with conda create --file ENV.yml. When disk space runs short, conda clean --all clears the caches that installs leave behind.

Questions

Does Anaconda Navigator have keyboard shortcuts?

Very few. Anaconda's Navigator documentation lists none, and the Navigator 2.7.2 source binds these keys in the main window: Ctrl + P for Preferences, Ctrl + R for Restart, Ctrl + Q for Quit, F6 for the logs viewer, F11 for full screen and F5 to reload the style sheet. There are no keys for creating environments, installing packages or launching Jupyter, Spyder or VS Code.

Are these the same commands Navigator runs?

They drive the same engine. Anaconda's documentation says Navigator uses the conda package and environment manager to create environments, so a button in Navigator and a command such as conda create --name ENVNAME do the same kind of work. Navigator adds the visual layer; the terminal adds scriptability.

What is the exported environment file for?

Reproducibility. conda export --file=environment.yaml writes the environment to a file and conda create --file ENV.yml builds an environment from one. The YAML and JSON formats are meant to work across platforms; conda export --format=explicit is tied to one platform and to exact builds.

How do I delete a conda environment?

conda remove --name ENVNAME --all removes every package and the environment itself; conda env remove --name myenv is the other spelling. To empty an environment but keep it, use conda remove -n myenv --all --keep-env.

Why does conda activate not work in a new terminal?

conda activate ENVNAME depends on shell setup that conda init adds, and most shells must be closed and reopened after running it. In scripts that do not read the shell startup files, conda run -n my-python-env python --version shows the alternative: run one command in an environment without activating it.

How do I free disk space used by conda?

conda clean --all removes the index cache, unused cached packages, tarballs, temporary files and log files. conda clean --tarballs and conda clean --packages remove one kind at a time.

Sources and checks

13 more source pages

Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.

17 rows from the earlier version of this page were removed in that check: duplicates, and bindings the documentation does not list or lists differently.

Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.