Export and Import Environments
Write an environment to a file, then reproduce it in one command on another machine or image — key for collaboration and deployment.
Export to environment.yml
conda activate myenvconda env export > environment.ymlResulting environment.yml:
name: myenvchannels: - conda-forge - defaultsdependencies: - python=3.11 - numpy=1.26 - pandas=2.2 - pip - pip: - requests==2.31.0💡 The trailing
pip:section records pip-installed packages so pure-Python deps are not lost.
Minimal export (direct deps only)
conda env export includes all transitive deps, which can be too large to port. Maintain a minimal environment.yml:
name: myenvchannels: - conda-forgedependencies: - python=3.11 - numpy - pandas - pip - pip: - requestsCreate from file
On another machine:
conda env create -f environment.yml⚠️ If
environment.ymlcame fromconda env exportwith build strings (e.g.numpy=1.26.4=py311h...), rebuilding on a different platform may fail to find that build. Use the minimal form (justnumpy) to let Conda resolve.
Clone locally
Without a file, copy an env on the same machine (see Environment Commands):
conda create -n myenv-copy --clone myenv