Installing conda packages#
A conda packages is a compressed tarball (.tar.bz2
) or .conda
file that contains everything needed to install a specific piece of software in a conda environment. This includes:
The software/library itself and any required dependencies.
Metadata about the package (version, author, and so on).
Installation scripts and configuration information.
Pre-compiled binary files for different operating systems and architectures.
You can use the conda package manager to access and install over 8,000 open-source data science and machine learning conda packages from Anaconda’s public repository and thousands more community-developed packages published on Anaconda.org and conda-forge.
You can even build your own custom conda packages using the conda-build
tool, then share them with others by uploading them to a public channel on Anaconda.org or conda-forge.
Note
It is possible to use conda alongside pip to build your conda environments. However, using pip packages in a conda environment comes with some limitations. For more information, see Installing pip packages.
This page includes common conda commands for interacting with conda packages. For more detailed information about managing packages, see the official conda documentation.
Open Anaconda Prompt (Terminal on macOS/Linux) and follow these instructions. You can also use Anaconda Navigator to install conda packages with just a few clicks, if you prefer using a graphical user interface.
Searching for conda packages#
To use conda to search for a package:
# Replace <PACKAGE> with the name of the package you want to search for
conda search <PACKAGE>
By default, conda searches for packages in Anaconda’s default channels.
To search a specific channel for a package:
# Replace <PACKAGE> with the name of the package you want to search for
# Replace <CHANNEL> with the URL or name of the channel you want to search, e.g., conda-forge
conda search <CHANNEL>::<PACKAGE>
If you don’t specify a full URL in the command, conda invokes the channel alias to complete the URL. By default, this is https://conda.anaconda.org/<CHANNEL>
. You can change the channel alias to a different repository with channel_alias
. See the official conda documentation for channel alias configuration details.
The official conda documentation also includes more information about specifying channels.
Installing conda packages#
Use the conda install
command to install packages into an environment. If no environment is specified in the command, conda installs the package in the working environment. Run conda install --help
to see help information and a list of available options.
Note
For your projects, Anaconda strongly recommends creating a separate conda environment to work in, rather than installing your project packages in the base environment. This protects your base environment from breaking due to complex dependency conflicts and allows you to easily manage and reproduce your environment on other machines.
To install a conda package, run the following command:
# Replace <PACKAGE> with the name of the package you want to install
conda install <PACKAGE>
To install multiple packages, list the packages separated by a space:
# Replace <PACKAGE> with the name of the package you want to install
conda install <PACKAGE> <PACKAGE> <PACKAGE>
To install from a specific channel:
# 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
conda install <CHANNEL>::<PACKAGE>
For more information about specifying channels and setting channel aliases, see Searching a specific channel above.
To install a package in an environment other than your working 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
conda install <PACKAGE> --name <ENVIRONMENT>
Specifying package versions#
By default, when installing packages from the command line, conda retrieves the latest available versions from the repository channel. To define package versions, conda uses MatchSpec as its query language.
Here is an example command that installs NumPy version 2.2.2:
conda install numpy=2.2.2
You can also use wildcard characters and match ranges of packages with conda using MatchSpec. For more information, see the official conda documentation on match specifications.
Managing Python environments#
When you attempt to install a package in an environment, conda checks to see which version of Python is installed in your current environment (or the environment specified by the install command), and only installs packages that are compatible with that version of Python.
If a package you’re trying to install doesn’t have a version that’s compatible with the environment’s Python version, you can create a new environment that uses a different version of Python. Conda treats Python the same as any other package, so it’s easy to manage and update multiple installations.
To create a new environment and install a different version of Python:
# Replace <ENVIRONMENT> with the name of the new environment
# Replace <VERSION> with the specific version of Python you want to install
conda create --name <ENVIRONMENT> python=<VERSION>
See the official conda documentation for more information about managing Python.
Installing packages on a non-networked (air-gapped) computer#
To directly install a conda package from your local computer:
# Replace <PACKAGE_PATH/PACKAGE> with the relative path to the package.
conda install <PACKAGE_PATH/PACKAGE>.conda
Conda installs packages into the anaconda/pkgs
directory. Conda supports both .conda
and .tar.bz2
file types.
If conda cannot find the file, try using an absolute path name instead of a relative path name.
Caution
Installing a package directly from a local file does not resolve its dependencies. If your installed package does not work, you might have missing dependencies that need to be resolved manually.