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.
Compared with plain pip + venv, conda can manage both Python packages and non-Python dependencies from channels.
Core Concepts
baseenvironment: default conda runtime environment.- named environments: isolated project environments.
- channels: package sources.
- 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:
- Keep one
environment.ymlin repository root. - Pin major/minor versions for critical dependencies.
- Use one channel strategy and document it.
- 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:
- Prefer one primary channel (often
conda-forgefor open ecosystem). - 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:
- Install conda packages first.
- Install pip-only packages last.
Why: pip cannot fully account for conda solver constraints.
Common Troubleshooting
Problem: solver conflicts
Try:
- Relax version pins.
- Remove mixed channels.
- 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:
- Create env from YAML.
- Cache conda package directories.
- 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
- Keep environments project-specific.
- Prefer reproducible YAML over manual installs.
- Use strict channel priority.
- Rebuild from scratch regularly.
- 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.
Comments