Package Management Intermediate
Learn how to install, update, remove, and search for packages with Conda. Master version pinning, handle dependency conflicts, and understand when to use pip inside a Conda environment.
Installing Packages
# Install a single package $ conda install numpy # Install multiple packages at once (recommended) $ conda install numpy pandas scikit-learn matplotlib # Install from conda-forge channel $ conda install -c conda-forge polars # Install into a specific (non-active) environment $ conda install -n myenv numpy
Specifying Versions
# Exact version $ conda install numpy=1.24.3 # Minimum version $ conda install "numpy>=1.24" # Version range $ conda install "numpy>=1.24,<2.0" # Latest 1.24.x (fuzzy match) $ conda install numpy=1.24 # Multiple versioned packages $ conda install numpy=1.24 pandas=2.0 python=3.11
Updating Packages
# Update a specific package $ conda update numpy # Update all packages in the environment $ conda update --all # Update conda itself $ conda update conda
Removing Packages
# Remove a package $ conda remove numpy # Remove multiple packages $ conda remove numpy pandas matplotlib
Listing Installed Packages
# List all installed packages in active environment $ conda list # Search within installed packages $ conda list numpy # List packages in a specific environment $ conda list -n myenv # Show only packages installed via pip $ conda list | grep pypi
Searching for Packages
# Search for a package $ conda search scikit-learn # Search on conda-forge $ conda search -c conda-forge polars # See all available versions $ conda search numpy --info
Using pip Inside Conda
Some packages are only available on PyPI, not in Conda channels. You can safely use pip inside a Conda environment, but follow these guidelines:
# FIRST: Install everything available via conda $ conda install numpy pandas scikit-learn # THEN: Use pip for packages only on PyPI $ pip install some-pypi-only-package # IMPORTANT: Always use pip from the active conda env # Verify pip is from the right environment: $ which pip /home/user/miniconda3/envs/myenv/bin/pip
conda install again if possible. Conda does not track pip-installed packages, so further conda installs might overwrite or conflict with pip packages. Install all conda packages first, then pip packages last.
Resolving Dependency Conflicts
When Conda reports conflicts, try these strategies:
-
Install all packages together
Instead of installing one at a time, list all packages in a single
conda installorconda createcommand. -
Use conda-forge
The conda-forge channel often has more recent and compatible versions:
conda install -c conda-forge package_name -
Relax version constraints
If you pinned an exact version, try allowing a range instead.
-
Create a fresh environment
Sometimes starting fresh is faster than fixing a tangled environment.
-
Use Mamba
Mamba's faster solver often resolves dependencies that Conda's solver times out on.
Quick Reference
| Task | Command |
|---|---|
| Install package | conda install numpy |
| Install specific version | conda install numpy=1.24 |
| Update package | conda update numpy |
| Remove package | conda remove numpy |
| List installed | conda list |
| Search packages | conda search numpy |
| Install from channel | conda install -c conda-forge pkg |
Next Up
Learn about Conda channels — where packages come from and how to configure them for your workflow.
Next: Channels →
Lilly Tech Systems