Managing Conda Packages
Last updated on 2026-08-27 | Edit this page
Overview
Questions
- How do I export my environment for sharing?
- How do I recreate an environment from a file?
- How do I manage disk space used by environments?
Objectives
- Export environments to YAML files for reproducibility
- Recreate environments from exported files
- Understand platform-specific vs. cross-platform exports
- Monitor and manage disk usage from conda environments
Exporting Your Environment
When your analysis works perfectly, save the exact configuration:
This creates an environment.yml file with every package
and version:
Recreating from a File
Share environment.yml with collaborators. They can
recreate the exact environment:
Or with a different name:
This guarantees the same versions and reproducibility.
Checking Disk Usage
Watch Your Disk Quota
Conda environments can use hundreds of MB to several GB each. On shared systems with disk quotas, this matters. Regularly check your usage and clean up old environments to stay under your limit. On Sagehen HPC, /rhome and /bigdata share a 1 TB lab quota.
Conda environments live in ~/.conda/envs/:
BASH
$ du -sh ~/.conda/envs/
2.3G /rhome/<myusername>/.conda/envs/
$ du -sh ~/.conda/envs/*
2.1G /rhome/<myusername>/.conda/envs/deeplearning_2024
1.3G /rhome/<myusername>/.conda/envs/genomics_2024
500M /rhome/<myusername>/.conda/envs/myproject
Cleaning conda cache
Conda keeps package caches that can be large:
This removes unused packages and cached install files, potentially freeing 500 MB to 2 GB.
Challenge 1: Export and Recreate
- Activate your data_sci environment
- Export it to a YAML file
- Create a copy from the exported file
- List all your environments
The YAML file contains:
YAML
name: data_sci
channels:
- defaults
dependencies:
- numpy=...
- scipy=...
- pandas=...
- python=3.10.X
...
conda env list shows both environments:
data_sci /rhome/<myusername>/.conda/envs/data_sci
data_sci_copy /rhome/<myusername>/.conda/envs/data_sci_copy
This demonstrates reproducibility; you can reliably recreate your environment.
- Export with
conda env export > environment.ymlfor reproducibility - Recreate with
conda env create -f environment.yml - Use
--from-historyfor cross-platform environment files - Monitor disk usage with
du -sh ~/.conda/envs/* - Remove old environments with
conda env remove -n name - Clean conda cache with
conda clean --allto free space