Because conda is a command-line tool, this page outlines the most common workflows for installing packages in your environment using Anaconda Prompt (Terminal for macOS/Linux users). If you prefer to use a graphical interface, you can also perform these actions using Anaconda Navigator.
Anaconda strongly recommends creating separate conda environments for each of your projects. This protects your
Anaconda strongly recommends creating separate conda environments for each of your projects. This protects your
base environment from breaking due to complex package dependency conflicts, helps to simplify environment management, and aids in the reproducibility of your environment on other machines.Using conda install
Use theconda install command to install packages into an environment. Run conda install --help to see a list of available options.
- Single package
- Multiple packages
To install a single package, run the following command:
Replace <PACKAGE> with the name of the package you want to install.
Specifying an environment
If no environment is specified in the command, conda installs the requested package(s) in your currently active environment.
Replace <PACKAGE> with the name of the package you want to install.
Replace <ENVIRONMENT> with the name of the environment where you want to install the package.
Replace <ENVIRONMENT> with the name of the environment where you want to install the package.
Specifying a channel
By default, conda installs packages using the channel priorities defined in your.condarc configuration file. You can override this behavior in one of two ways, depending on how you want conda to handle the package dependencies:
- Using double-colon syntax
- Using the --channel flag
Using the double-colon syntax
:: in the command installs the specified package from the specified channel, but immediately falls back to your user-defined channel priorities to install any necessary package dependencies.Replace <PACKAGE> with the name of the package you want to install.
Replace <CHANNEL> with the URL or name of the channel you want to install from.
Replace <CHANNEL> with the URL or name of the channel you want to install from.
Specifying package versions
By default, when installing packages from the command line, conda retrieves the latest possible versions of the requested package(s) (and their dependencies) that are compatible with the current environment. To define package versions, conda uses MatchSpec as its query language. MatchSpec also allows for wildcard characters and match ranges. For more information, see the official conda documentation on match specifications. Here is an example command that installs NumPy version2.2.2 and its dependencies:
Downloading a package file
Conda downloads package archive files (.conda or .tar.bz2) to your package cache when you install a new package. This makes conda more efficient when you need to use the same package in multiple places, but the package cache also enables you to copy or use the package archive file in different ways.
Where is my package cache?
Where is my package cache?
Your package cache is located in the
/pkgs folder of your installation folder. Possible default installation locations include:| Operating System | Installer | File Location |
|---|---|---|
| Windows | Graphical installer (.exe) | \Users\<USERNAME>\anaconda3\ |
| macOS | Graphical installer (.pkg) | /opt/anaconda3/ |
| macOS | Command line installer (.sh) | /anaconda3/ |
| Linux | Command line installer (.sh) | /anaconda3/ |
Replace
To see your exact package cache file location, open Anaconda Prompt (Terminal in macOS/Linux) and run the following command:
anaconda3 with miniconda3 for Miniconda installationsTo see your exact package cache file location, open Anaconda Prompt (Terminal in macOS/Linux) and run the following command:
Replace <PACKAGE> with the name of the package you want to download.
Optionally, specify the package <VERSION>.
Optionally, specify the package <VERSION>.
How do I know what file type a package is?
How do I know what file type a package is?
One way to determine what archive file type a package install uses is to use the The extension in the file name and url for each package version shows what type of file will be downloaded:
--info flag when searching for the package:Replace <PACKAGE> with the name of the package you are searching for.
Optionally, specify the package <VERSION> to shorten the search list.
Optionally, specify the package <VERSION> to shorten the search list.
Example package information
Installing packages from a local file (air-gapped networks)
If you’re working on a machine without internet access, you can install packages in an environment directly from.conda or .tar.bz2 files that are stored on your local file system:
Replace <PATH_TO_PACKAGE> with the relative or absolute path to the package file.
.conda and .tar.bz2 file types, but .conda archive files are the most common. For more information on the .conda file format, see .conda file format in the official conda documentation.
Troubleshooting
command not found: conda
Cause
The
command not found: conda error occurs when your command line interface (CLI) can’t find the conda command in order to use it. This might be because:- You don’t have conda properly initialized.
- You have set
auto_activate_basetofalse. - You’re using a shell that conda doesn’t support.
- Conda is not installed or the install was incomplete or corrupted.
These issues primarily occur on macOS/Linux computers. Anaconda Distribution and Miniconda installations on Windows include Anaconda Prompt, which opens with conda initialized by default.
Solution
Initialize conda in your shell
Initialize conda in your shell
If you recently installed Anaconda Distribution or Miniconda, make sure you closed and reopened your CLI to make conda’s initialization take effect.You can also initialize conda directly from its
bin directory:Replace <PATH_TO_CONDA> with a path to your conda installation.
Set auto_activate_base to true
Set auto_activate_base to true
To see the value for If your terminal returns If you have
auto_activate_base, run the following command:false, this means that conda is not automatically activating your base environment when you start a new shell. This behavior emulates your system Python, and some users prefer to have their conda environment be inactive until they need it. However, this is not conda’s default behavior after installation.To change the value of auto_activate_base to true, run the following command:auto_activate_base set as false, the conda command will still be available as a shell function, but your base environment will not be active when a new shell is started. To activate your base environment, run conda activate.Use a shell that conda supports
Use a shell that conda supports
For information on which shells conda supports, see Conda activate in the official conda documentation.
Verify your installation of conda
Verify your installation of conda
If you have tried to initialize conda in your shell but it didn’t work, try uninstalling and reinstalling Anaconda Distribution or Miniconda.
DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment
Cause
This error means that you don’t have a conda environment currently active. You might have used
conda deactivate while in your base environment and deactivated conda.Solution
Activate your
base environment or another environment:Replace <ENV_NAME> with the name of the environment.