Conda Cheatsheet#
Pip#
Command | Desc |
---|---|
pip show <PKG> |
show installed version of <PKG> |
pcu requirements.txt |
what if version of pip-check-updates i.e. won't modify requirements.txt |
pcu requirements.txt -u |
update requirements.txt package file |
pcu requirements.txt -i |
interactive version of pip-check-updates |
Conda#
Command | Desc |
---|---|
Managing Environments | |
conda info |
get version info |
conda create --name <ENV> python=3.10 |
create new environment with package list |
conda env create --name <ENV> --file env.yml |
create new environment from file |
conda env remove --name <ENV> --all |
delete an entire environment |
conda activate <ENV> /conda deactivate |
activate/deactivate environment |
conda list --explicit > spec.txt |
produce an environment spec file |
conda env export --from-history > env.yml |
export environment to file |
conda clean |
remove unused packages and caches |
conda doctor -n <ENV> [-vvv] |
display a health report for env |
conda clean [--index-cache] [--packages] [--tarballs] [--logfiles] [--locks] |
remove index cache, unused cached packages, tarballs, logfiles, and lock files |
conda clean -all -vvv --dry-run |
clean everything |
conda doctor -n <ENV> -vvv |
display health report for env |
Managing Packages | |
conda install <PKG>==<VER> |
install specific package version |
conda install --file requirements.txt |
install from requirements file |
conda update conda |
update conda base |
conda update python |
update python version |
conda update anaconda |
update all packages to latest stable + compatible version of Anaconda |
conda update -n base conda |
update base conda environment |
conda env update -n <ENV> --file env.yml --prune |
update environment from file and uninstall unused dependencies |
Mamba#
Command | Desc |
---|---|
Managing Environments | |
mamba info |
get version info |
mamba env list |
list environments |
mamba create -n <ENV> <PKG> |
create an environment |
mamba env create --file env.yml |
import an environment |
mamba env export -n <ENV> --no-builds |
show details of environment |
mamba env export -n <ENV> > env.yml |
export an environment |
mamba env remove -n <ENV> |
remove an environment |
mamba env update -n <ENV> --file env.yml --prune |
update environment from file/uninstall unused dependencies |
mamba create -n CLONE_ENV_NAME --clone <ENV> |
clone an existing environment |
mamba activate <ENV> /mamba deactivate |
activate/deactivate environment |
mamba clean [--index-cache] [--packages] [--tarballs] [--logfiles] [--locks] |
clean environment remove index cache, unused cached packages, tarballs, logfiles, and lock files |
mamba clean -all -vvv --dry-run |
clean everything |
conda doctor -n <ENV> -vvv |
display health report for env |
Managing Packages | |
mamba install -n <ENV> <PKG> |
install package |
mamba update --all |
update mamba, base env, etc |
mamba update -n base mamba |
update mamba base |
mamba update -n <ENV> <PKG> |
update package |
mamba remove -n <ENV> <PKG> |
removing a package |
mamba repoquery search <PKG> |
finding a package |
mamba repoquery depends <PKG> [--recursive] |
show pkg direct/transitive dependencies |
mamba repoquery depends -t <PKG> |
show pkg transitive dependencies as tree |
mamba repoquery whoneeds <PKG> |
show pkg dependants i.e. inverse of depends |
mamba repoquery whoneeds -t <PKG> |
show pkg dependants as tree |
Migrating Environments#
- Using
conda-minify
to export minimal environment
Bashconda install conda-minify -c jamespreed conda-minify --name <ENV> [--relax] [--how [full|minor]] [--file ./test_env.yml]