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.
| Command | What it does |
|---|---|
conda create --name ENVNAME | Create an environmentMakes a new environment under that name; package specs added after it are installed straight away. |
conda create --name ENVNAME python=3.10 | Create with a chosen PythonPins the interpreter version at the moment the environment is built. |
conda create -n myenv python=3.12 numpy | Create with packagesUses the short -n flag and installs every listed spec while the environment is being made. |
conda activate ENVNAME | Activate an environmentSwitches the current shell to that environment, so later installs land in it. |
conda activate | Switch back to default environmentWith no name it goes to the default environment, which the guide prefers over deactivating. |
conda deactivate | Deactivate current environmentLeaves the active environment; run from base, it can leave the shell unable to find conda. |
conda info --envs | List environments and pathsThe environment marked with an asterisk is the active one. |
conda env list | List all environmentsPrints the same list as the info command with --envs. |
conda create --clone ENVNAME --name NEWENV | Clone an environmentBuilds NEWENV as a copy of an environment that already exists on this machine. |
conda rename --name ENVNAME NEWENVNAME | Rename an environmentTakes the present name after --name and the replacement as the last argument. |
conda remove --name ENVNAME --all | Delete an environmentThe --all flag removes every package and then the environment itself. |
conda env remove --name myenv | Delete with env removeSecond way to delete an environment, offered by the guide beside conda remove with --all. |
conda remove -n myenv --all --keep-env | Empty an environmentUninstalls everything inside it but leaves the environment in place. |
conda run -n my-python-env python --version | Run a program in an environmentExecutes one command inside the named environment, an alternative to activating it first. |
Environment history and variables 5
| Command | What it does |
|---|---|
conda list --name ENVNAME --revisions | List environment revisionsShows the numbered history of changes that a rollback can point to. |
conda install --name ENVNAME --revision NUMBER | Roll back to a revisionReturns the environment to the state saved under that number. |
conda env config vars set my_var=value | Set an environment variableThe variable only takes effect after the environment has been activated again. |
conda env config vars list | List 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-env | Unset 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.
| Command | What it does |
|---|---|
conda export --format=environment-yaml | Export as YAMLWrites an environment spec that the cheat sheet marks as usable on other platforms. |
conda export --format=environment-json | Export as JSONThe same portable spec, written in JSON syntax. |
conda export --from-history | Export only requested specsBuilds the spec from the packages that were explicitly requested, as recorded in the environment history. |
conda export --format=explicit | Export an explicit listThe result is tied to one platform and to exact package builds. |
conda export --format=requirements | Export a requirements listPlatform and package specific like the explicit format, in requirements form. |
conda export --file=environment.yaml | Export to a named fileThe output format is detected from the name of the file. |
conda env export > environment.yml | Export with the older commandYAML only; the file covers pip packages as well as conda ones. |
conda create --file ENV.yml | Create from a YAML fileThe new environment takes its name from the file's first line. |
conda create --name ENVNAME --file ENV.txt | Create from a text fileBuilds a named environment out of a package list saved as text. |
conda env create -f /path/to/environment.yml | Create from a definition fileThe spec is solved when it is installed; -f is needed whenever the file sits in another directory. |
conda env update --prune | Sync environment with its fileApplies environment.yml again and uninstalls whatever the file has stopped listing. |
conda list --explicit | List packages with their URLsPrints a spec list that create --file can rebuild from on the same platform. |
conda list --export > package-list.txt | Save the package listStores requirement strings in a file that create --file can read back. |
Installing and updating packages 15
| Command | What it does |
|---|---|
conda install scipy | Install a packageWith no -n or -p flag the package goes into whichever environment is active. |
conda install --name ENVNAME PKGNAME1 PKGNAME2 | Install into a named environmentSeveral package names can follow, and the target need not be active. |
conda install PKGNAME=3.1.4 | Install 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 --yes | Install without the promptAnswers the confirmation question automatically; the flag works on other conda commands too. |
conda install pip | Add pip to the environmentPuts pip inside the active environment, so what it installs shows up in conda list. |
conda update --all | Update all packagesWorks on the active environment unless a name is added. |
conda update --all --name ENVNAME | Update a named environmentConfines the update to that environment, whichever one is active. |
conda update biopython | Update one packageConda reports what would change and lets you decide before anything is installed. |
conda update python | Update PythonStays within the current series: a 3.x interpreter moves to the highest 3.x release available. |
conda update --name base conda | Update conda itselfTargets the base environment, where the conda program is installed. |
conda uninstall PKGNAME | Uninstall a packageTakes the package out of the environment that is active. |
conda uninstall --name ENVNAME PKGNAME | Uninstall from a named environment |
conda remove -n myenv scipy curl wheel | Remove several packagesAnything that depends on them goes too, unless conda finds a replacement without that dependency. |
Listing and searching packages 8
| Command | What it does |
|---|---|
conda list | List installed packagesCovers the active environment and includes packages that pip installed there. |
conda list --name ENVNAME --show-channel-urls | List packages of another environmentNames the environment to inspect and adds the channel each package came from. |
conda list ^py | Filter the list by regexShows only names matching the regular expression, here those starting with py. |
conda list --fields name,version | Choose the list columnsPrints just the fields given, separated by commas. |
conda search scikit-learn | Search for a package |
conda search PKGNAME --info | Show 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
| Command | What it does |
|---|---|
conda config --show channels | Show configured channelsLists the channels conda is set to use at the moment. |
conda config --show-sources | Show configuration sourcesDisplays each configuration file conda identified, which is where channel lists come from. |
conda config --add channels CHANNELNAME | Add a channel at the topThe new channel goes first in the list and so gets the highest priority. |
conda config --prepend channels new_channel | Prepend a channelEquivalent to --add: the channel is placed first. |
conda config --append channels new_channel | Append a channelPuts the channel last, which gives it the lowest priority. |
conda config --remove channels defaults | Remove the defaults channelAdd another channel first: conda errors when the only configured channel is taken away. |
conda config --set channel_priority strict | Turn on strict channel priorityAdvised only when channels have to be mixed; some environments may then fail to solve. |
conda config --set channel_priority disabled | Turn off channel priorityConda then takes the newest version of a package from any listed channel. |
conda install --channel CHANNELNAME PKGNAME | Install from a channelSearches that channel first for this one command, ahead of the channels already configured. |
conda install CHANNELNAME::PKGNAME | Install one package from a channelOnly that package comes from the channel; dependencies resolve from the configured ones. |
conda install --channel conda-forge --override-channels numpy | Install from one channel onlyIgnores every channel configured in .condarc for the duration of the command. |
conda search conda-forge::numpy | Search one channel |
conda list --show-channel-urls | Show where packages came fromAdds the source channel of every installed package to the listing. |
Configuration and shell setup 9
| Command | What it does |
|---|---|
conda config --show | Show configuration valuesPrints all settings as conda has worked them out from every source. |
conda config --describe channel_priority | Describe a settingPrints the built-in explanation of the option that is named. |
conda config --set verbosity 3 --env | Set 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 KEY | Delete a configuration keyTakes the key out together with every value stored under it. |
conda config --add create_default_packages PACKAGENAME1 PACKAGENAME2 | Set default packagesFrom then on the named packages are installed into each environment you create. |
conda config --set notify_outdated_conda false | Silence the update warningStops the message that tells you a newer conda is available. |
conda init | Set up shell integrationMost shells have to be closed and reopened before the change applies. |
conda init --reverse | Undo the shell setupReverts what the most recent init run changed. |
conda init --condabin | Put only condabin on PATHLeaves the shell function out, so just the conda executable becomes reachable. |
Information, health checks and cleanup 10
| Command | What it does |
|---|---|
conda info | Show installation detailsPrints version and setup details, which also confirms that conda is installed. |
conda --version | Show the conda versionConda answers with the version number that is installed. |
conda COMMAND --help | Get help for a commandReplace COMMAND with a subcommand such as create or install to see its options. |
conda doctor | Check environment healthRuns the registered health checks; the same report is available under the name conda check. |
conda doctor --list | List the health checksShows every check that exists and whether a fix is attached to it. |
conda doctor --fix | Repair detected problemsAsks for confirmation before changing anything unless --yes is added. |
conda clean --all | Clear caches and unused filesDeletes the index cache, unused cached packages, tarballs, temporary files and log files. |
conda clean --index-cache | Clear the index cache |
conda clean --packages | Remove unused cached packagesEnvironments that conda info --envs does not list are not checked for links into the cache. |
conda clean --tarballs | Remove cached tarballs |
No row on this page matches that filter.
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
- conda 26.9.1 documentation — Cheatsheet Everyday commands in every section: environments, packages, channels, export and import
- conda 26.9.1 documentation — Managing environments Activating and deactivating, environment variables, env update, env remove
- conda 26.9.1 command reference — conda create Creating an environment from package specs
- conda 26.9.1 command reference — conda install Installing into the active environment
- conda 26.9.1 command reference — conda remove Removing packages; --all and --keep-env
- conda 26.9.1 command reference — conda list Listing, filtering and exporting the package list
13 more source pages
- conda 26.9.1 command reference — conda search Searching by name, version, channel and platform
- conda 26.9.1 command reference — conda config Describing, setting and removing configuration keys
- conda 26.9.1 command reference — conda clean Cache removal targets
- conda 26.9.1 documentation — Managing channels Channel order, channel priority, installing from one channel
- conda 26.9.1 documentation — Managing packages Updating single packages, pip inside an environment, default packages
- conda 26.9.1 documentation — Managing conda Checking the conda version, update warning
- conda 26.9.1 command reference — conda run Running a program in an environment
- conda 26.9.1 command reference — conda init Shell setup
- conda 26.9.1 command reference — conda doctor Environment health checks
- conda 26.9.1 command reference — conda env create Creating an environment from a definition file
- Anaconda documentation — Channels Viewing the channel list and removing a channel
- Anaconda Navigator 2.7.2 source — widgets/main_window/__init__.py (official package on repo.anaconda.com) The keys the Navigator window itself binds
- Anaconda documentation — Anaconda Navigator What Navigator is; its documentation lists no keyboard shortcuts
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.