Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/conda/conda/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Conda packages are compressed archives containing compiled software, libraries, and metadata. This guide covers how to install, update, and manage packages in your conda environments.
Conda handles package dependencies automatically, ensuring all required packages are installed together.

Package Formats

Conda supports two package formats:
CONDA_PACKAGE_EXTENSION_V1 = ".tar.bz2"  # Legacy format
CONDA_PACKAGE_EXTENSION_V2 = ".conda"    # Modern format (faster)
The .conda format is significantly faster to extract and is preferred for new packages.

Installing Packages

Basic Installation

Use conda install to add packages to your environment:
# Install into active environment
conda install numpy

# Install specific version
conda install numpy=1.24.3

# Install with version constraint
conda install "numpy>=1.24,<2.0"
Conda installs the newest compatible versions of requested packages by default. Use version specifiers to control which version is installed.

Installation Options

# Install from conda-forge
conda install -c conda-forge package_name

# Install from multiple channels
conda install -c conda-forge -c bioconda biopython
# Install from requirements file
conda install --file requirements.txt

# Install from environment file
conda install --file environment.yml
# Skip dependency checking (use with caution)
conda install --no-deps package_name
Using --no-deps may result in an environment with incompatible packages. Use this option only when you’re certain dependencies are already satisfied.
# Install from local file
conda install ./package-1.0.0-py311.tar.bz2

# Install from URL
conda install https://example.com/package-1.0.0-py311.conda
Installing explicit filenames implies --no-deps and cannot be mixed with package specifications.

Advanced Installation Options

# Prevent updates to existing packages
conda install --freeze-installed new_package

Package Specifications

MatchSpec Syntax

Package specifications in conda use the MatchSpec format:
# Exact version
numpy==1.24.3

# Greater than or equal
numpy>=1.24

# Range
"numpy>=1.24,<2.0"

# Compatible release
numpy~=1.24.0  # equivalent to >=1.24.0,<1.25.0

Updating Packages

Update Individual Packages

# Update to latest version
conda update numpy

# Update in specific environment
conda update -n myenv numpy

# Update to specific version
conda install numpy=1.25.0

Update All Packages

# Update all packages in active environment
conda update --all

# Update all in specific environment
conda update -n myenv --all
Updating all packages may change many package versions. Consider using --dry-run first to preview changes.

Aggressive Update Packages

Certain packages are updated aggressively for security:
DEFAULT_AGGRESSIVE_UPDATE_PACKAGES = (
    "ca-certificates",
    "certifi",
    "openssl",
)
These security-related packages are prioritized for updates to ensure your environment stays secure.

Update Modifiers

Control how dependencies are updated:
# Update only specified packages (default)
conda install --update-specs numpy

# Update dependencies of specified packages
conda install --update-deps numpy

# Update all packages possible
conda install --update-all numpy

# Freeze installed packages (don't update deps)
conda install --freeze-installed numpy

Removing Packages

Remove Individual Packages

# Remove from active environment
conda remove numpy

# Remove from specific environment
conda remove -n myenv numpy

# Remove from path
conda remove -p /path/to/myenv numpy

Remove with Options

# Remove package but keep dependencies
conda remove --no-deps numpy
# Remove packages that are no longer required
conda install --prune
Use --prune after removing packages to clean up orphaned dependencies.
# Remove all packages from environment
conda remove -n myenv --all
This deletes the entire environment. Use conda env remove instead for clarity.

Protected Packages

Some packages in the base environment cannot be removed:
ROOT_NO_RM = (
    "python",
    "pycosat",
    "ruamel.yaml",
    "conda",
    "openssl",
    "requests",
)
These packages are essential for conda’s operation and are protected from removal in the base environment.

Listing Packages

Basic Listing

# List packages in active environment
conda list

# List in specific environment
conda list -n myenv

# List in reverse order
conda list --reverse

Custom Output Formats

# Export package list for reinstallation
conda list --export > package-list.txt

# Reinstall from export
conda create -n newenv --file package-list.txt
# Export with full URLs
conda list --explicit > explicit-spec.txt

# Create exact replica
conda create -n replica --file explicit-spec.txt
# Show only name and version
conda list --fields name,version

# Show with channel information
conda list --fields name,version,channel
Available fields:
DEFAULT_CONDA_LIST_FIELDS = (
    "name",
    "version",
    "build",
    "channel_name",
)

# Other available fields:
# arch, build_number, channel, constrains, depends,
# dist_str, features, fn, license, license_family,
# md5, noarch, package_type, requested_spec, sha256,
# size, subdir, timestamp, track_features, url
# Output canonical package names only
conda list --canonical

JSON Output

# Output as JSON for scripting
conda list --json

# Specific package in JSON
conda list numpy --json

Package Dependencies

Understanding Dependencies

Every package declares its dependencies in metadata. Conda automatically resolves and installs these dependencies.
class DepsModifier(Enum):
    NOT_SET = "not_set"      # Default: handle normally
    NO_DEPS = "no_deps"      # Skip dependencies
    ONLY_DEPS = "only_deps"  # Install only dependencies

Install Only Dependencies

# Install dependencies but not the package itself
conda install --only-deps numpy
Useful when you’re building the main package from source but need its dependencies.

Package Revisions

View Revision History

Conda tracks all changes to your environment:
# List all revisions
conda list --revisions

# Show specific revision
conda list --revision 5

Revert to Previous Revision

# Revert to specific revision number
conda install --revision 5

# View revision before reverting
conda install --revision 5 --dry-run
Reverting to a previous revision may downgrade packages or remove packages that were installed later.

Package Conflicts and Resolution

Path Conflicts

When packages try to install files to the same location:
class PathConflict(Enum):
    clobber = "clobber"    # Overwrite files
    warn = "warn"          # Warn but continue
    prevent = "prevent"    # Stop installation
# Allow overwriting files
conda install --clobber package_name

Safety Checks

class SafetyChecks(Enum):
    disabled = "disabled"  # No safety checks
    warn = "warn"          # Warn about issues
    enabled = "enabled"    # Enforce safety

Solver Selection

Conda can use different solvers for dependency resolution:
DEFAULT_SOLVER = "libmamba"  # Modern, fast solver
CLASSIC_SOLVER = "classic"   # Legacy solver
# Use specific solver
conda install --solver=classic numpy

# Use default (libmamba)
conda install numpy
The libmamba solver is significantly faster than the classic solver and is now the default.

Package Cache Management

View Cache

# Show cache information
conda info

# List cached packages
conda clean --dry-run --packages

Clean Cache

# Remove unused cached packages
conda clean --packages

# Remove all cached data
conda clean --all

# Preview what would be removed
conda clean --all --dry-run
Regularly cleaning the package cache can free up significant disk space.

Partial Downloads

During downloads, partial files are marked:
PARTIAL_EXTENSION = ".partial"
If a download is interrupted, the .partial file remains and the download can be resumed.

Best Practices

Prevent critical packages from being updated:
echo "python 3.11.*" >> $CONDA_PREFIX/conda-meta/pinned
echo "numpy 1.24.*" >> $CONDA_PREFIX/conda-meta/pinned
Preview changes before committing:
conda update --all --dry-run
conda remove large_package --dry-run
When available, use conda packages instead of pip:
# Preferred
conda install numpy

# Fallback
pip install numpy
Conda packages include compiled dependencies and are better integrated.
Install project-specific packages in separate environments:
# In base: only conda and essential tools
conda activate base
conda install conda-build

# Project packages in separate env
conda create -n project1 numpy pandas

Troubleshooting

Try using the libmamba solver:
conda install --solver=libmamba package_name
Or reduce the search space:
conda install --freeze-installed package_name
Check which channels are being searched:
conda config --show channels
Try a different channel:
conda install -c conda-forge package_name
Create a new environment for conflicting requirements:
conda create -n separate_env package_with_conflict
Or use a constraints file to guide the solver.
Search for available versions:
conda search package_name

# Search in specific channel
conda search -c conda-forge package_name

Next Steps

Channel Management

Learn how to configure and prioritize package channels

Environment Management

Manage environments for your packages