This document provides a concise reference for creating, locating, customizing, exporting, renaming, and removing Conda virtual environments on macOS (and other platforms). Use it as a cheat sheet in your projects.
- Conda is a cross-platform package and environment manager.
- Installs packages (Python and non-Python) and manages isolated environments under a central
condainstallation.
# Create a new env called "myenv" with Python 3.10
conda create -n myenv python=3.10conda create --prefix /path/to/envs/myenv python=3.10-
Use full path for activation: conda activate /path/to/envs/myenv
-
In a YAML manifest, replace name: with:
prefix: /path/to/envs/myenvconda info --baseconda env listor
conda info --envs# Minimal (explicit installs only)
conda env export --from-history > environment.yml
# Full (all dependencies)
conda env export > environment.ymlname: myenv # or 'prefix: /path/to/env'
channels:
- defaults
dependencies:
- python=3.10
- numpy
- pandas
- pip
- pip:
- package-only-on-pip==1.2.3### Conda Envs
conda env remove -n myenv
# or
conda remove --name myenv --all
# By path
conda env remove --prefix /full/path/to/env# If active, first deactivate
deactivate
# Then delete the directory
rm -rf /path/to/env_dir