Skip to main content

Conda Commands: Practical Environment Management Guide

Created: April 24, 2026 CalmOps 3 min read

Why Conda Still Matters

Conda is useful when projects require binary-heavy Python packages, mixed language dependencies, or reproducible data and ML environments across different operating systems. See Python Guide for more context. See Python Guide for more context. See Python Guide for more context.

Compared with plain pip + venv, conda can manage both Python packages and non-Python dependencies from channels.

Core Concepts

  1. base environment: default conda runtime environment.
  2. named environments: isolated project environments.
  3. channels: package sources.
  4. solver: dependency resolver that computes compatible package graph.

Install and Verify

conda --version
conda info

If conda command is not found, ensure shell initialization is complete:

conda init bash
exec "$SHELL"

Environment Lifecycle Commands

List environments

conda env list
# or
conda info --envs

Create environment with specific Python version

conda create -n myenv python=3.11

Activate and deactivate

conda activate myenv
conda deactivate

Remove environment

conda remove -n myenv --all

Package Management Commands

List packages

conda list
conda list -n myenv

Install package

conda install numpy
conda install -n myenv pandas

Install from specific channel

conda install -c conda-forge pyarrow

Update package

conda update numpy

Update conda itself

conda update conda

Environment Reproducibility

Export full environment

conda env export > environment.yml

Create from environment file

conda env create -f environment.yml

Update existing env from file

conda env update -f environment.yml --prune

--prune removes packages not listed in the YAML, which helps keep drift low.

Better Team Workflow

Recommended process:

  1. Keep one environment.yml in repository root.
  2. Pin major/minor versions for critical dependencies.
  3. Use one channel strategy and document it.
  4. Rebuild env from scratch periodically in CI.

Example environment.yml:

name: analytics
channels:
 - conda-forge
dependencies:
 - python=3.11
 - numpy=1.26
 - pandas=2.2
 - jupyterlab
 - pip
 - pip:
   - fastapi==0.115.0

Channel Strategy and Priority

Mixing channels carelessly can cause hard-to-debug solver conflicts.

Recommended:

  1. Prefer one primary channel (often conda-forge for open ecosystem).
  2. Set channel priority explicitly.
conda config --set channel_priority strict
conda config --add channels conda-forge

Speeding Up Solves with Mamba

For large dependency graphs, use mamba (or micromamba) as faster solver.

conda install -n base -c conda-forge mamba
mamba create -n ds python=3.11 numpy pandas

Mamba keeps conda-compatible workflows while reducing solve time significantly.

Conda + Pip Interoperability

Use this order for fewer conflicts:

  1. Install conda packages first.
  2. Install pip-only packages last.

Why: pip cannot fully account for conda solver constraints.

Common Troubleshooting

Problem: solver conflicts

Try:

  1. Relax version pins.
  2. Remove mixed channels.
  3. Recreate env from clean YAML.

Problem: activate not working in shell

conda init bash
exec "$SHELL"

Problem: broken env after many ad-hoc installs

Best fix is usually rebuild:

conda remove -n myenv --all
conda env create -f environment.yml

Problem: huge disk usage

Clean package caches:

conda clean --all

CI/CD Usage Pattern

In CI:

  1. Create env from YAML.
  2. Cache conda package directories.
  3. Run tests inside that environment.

This catches dependency drift early.

Practical Command Cheat Sheet

# create
conda create -n proj python=3.11

# activate
conda activate proj

# install
conda install numpy pandas

# export
conda env export > environment.yml

# recreate
conda env create -f environment.yml

# remove
conda remove -n proj --all

Best Practices Summary

  1. Keep environments project-specific.
  2. Prefer reproducible YAML over manual installs.
  3. Use strict channel priority.
  4. Rebuild from scratch regularly.
  5. Use mamba for speed on complex stacks.

Conclusion

Conda is most effective when treated as environment infrastructure, not ad-hoc package installation. With a clear YAML workflow and disciplined channel strategy, you get reliable local development and predictable team onboarding.

Resources

Comments

Share this article

Scan to read on mobile