Take over an existing conda environment
You just joined a team or lab that uses conda. Someone handed you an environment.yml and told you to conda activate. This tutorial walks through the day-to-day operations: creating an environment from a file, exploring what’s installed, adding packages, handling the conda+pip boundary, and exporting a reproducible environment for teammates.
Prerequisites
Install Miniforge following the Miniforge installation instructions.
Important
Use Miniforge, not Miniconda or Anaconda. Miniforge defaults to the conda-forge channel, which is community-maintained and freely licensed. Miniconda and Anaconda default to the defaults channel, which requires a paid license for commercial use at organizations with more than 200 employees. See Is Conda Actually Free? for the full licensing picture.
After installation, verify conda is available:
conda --versionUnderstand what you’ve been given
The environment.yml file describes a conda environment. Here is a realistic example (save this as environment.yml to follow along):
name: analysis
channels:
- conda-forge
dependencies:
- python=3.12
- pandas=2.2
- matplotlib=3.9
- scikit-learn=1.5
- jupyter
- pip:
- seabornThe key fields:
name: the environment name. You’ll use this withconda activate analysis.channels: where conda fetches packages.conda-forgeis the most common community channel.dependencies: packages installed from conda channels. Version pins likepython=3.12lock to a minor version; unpinned packages likejupyterget the latest compatible release.pip: packages installed from PyPI after the conda packages. Some packages (like seaborn in this example) are available on both conda-forge and PyPI. Thepip:section is for packages that are only on PyPI or that the team chose to install via pip.
Create the environment
conda env create -f environment.ymlThis resolves all dependencies, downloads packages, and creates a named environment. The process can take a few minutes on the first run.
Activate the environment:
conda activate analysisYour shell prompt changes to show the active environment name. Every python, pip, or jupyter command now uses this environment’s packages.
Explore the environment
List installed packages:
conda listThis shows every package, its version, build string, and channel. The output is long. Filter it to find a specific package:
conda list pandasCheck environment metadata:
conda infoThis prints the active environment path, Python version, and conda configuration. The environment lives on disk as a directory (typically under ~/miniforge3/envs/analysis/ or wherever Miniforge is installed).
Add a new dependency
Your work requires a package that wasn’t in the original environment.yml. Install it with conda:
conda install scipyConda resolves the new package against everything already installed and updates the environment. If the resolution takes too long or produces conflicts, pin fewer versions in environment.yml or check for incompatible version constraints.
Handle the conda + pip boundary
Sometimes you need a package that only exists on PyPI, not on conda-forge. Install it with pip inside the active conda environment:
pip install watermarkWarning
Mixing conda and pip requires care. Always install conda packages first, then pip packages. If you conda install something after using pip, conda doesn’t know about pip’s packages and can overwrite or break them. The safe ordering is: build the conda environment, then add pip packages at the end.
Check what pip installed (as opposed to conda):
pip list --format=freeze | head -20The environment.yml captures this split with the pip: subsection under dependencies. When you export the environment later, both conda and pip packages are included.
Export the environment for teammates
After adding packages, export the updated environment so teammates can reproduce it.
For cross-platform sharing, use --from-history:
conda env export --from-history > environment.ymlThis exports only the packages you explicitly requested (not platform-specific transitive dependencies), making the file portable across macOS, Linux, and Windows.
Note
--from-history does not capture pip-installed packages. If your environment includes pip packages, add them manually to the pip: section of environment.yml after exporting.
For an exact reproduction on the same platform, export everything:
conda env export > environment-lock.ymlThis includes every transitive dependency with exact versions and build strings. It only works on the same OS and architecture.
Remove the environment
When you’re done with an environment or need to start fresh:
conda deactivate
conda env remove -n analysisRecreate it anytime from the environment.yml file.
Next steps
- Understanding the Conda/Anaconda Ecosystem for a map of how conda, Anaconda, Miniforge, and conda-forge relate
- Is Conda Actually Free? for licensing details
- uv vs pixi vs conda for Scientific Python to compare conda with modern alternatives
- Migrate a Conda Project to pixi to modernize an existing conda workflow