Skip to content

Instantly share code, notes, and snippets.

@abidanBrito
Last active September 27, 2023 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abidanBrito/ce9266fdd6cea6e401ceae7ac0effd9b to your computer and use it in GitHub Desktop.
Save abidanBrito/ce9266fdd6cea6e401ceae7ac0effd9b to your computer and use it in GitHub Desktop.

Conda Cheatsheet

Set up

Installing miniconda

curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Updating miniconda

conda update conda
conda -v (check version)

Disable auto-activation (when firing up a prompt)

conda config --set auto_activate_base false

Channels

Listing active channels

conda config --show channels
conda config --show default_channels

Adding channels

conda config --append channels <channel_name>

Environments

Activating & deactivating environments

conda activate (base environment)
conda activate <env_name>
conda deactivate

Listing environments

conda env list
conda info --env

Creating environments

conda create -n <env_name> (empty env)
conda create -n <env_name> <pkg_name> (env with one package, can add more)
conda create -n <env_name> python=<version> (env with a specific python version)

Removing environments

conda env remove -name <env_name>
conda remove -n <env_name> --all (removes all packages and their dependencies)

Cloning environments

conda create -n <new_env_name> --clone <env_name>

Sharing an environment

conda env export > environment.yml
conda env create -f <path_to_yaml_file>

Cleaning an environment (unused packages, caches and temporary files)

conda clean --yes --all
conda clean --yes --packages

Packages

Using pip as a package manager

conda install -n <env_name> pip
conda activate <env_name>
pip <pip_subcommand>

Listing packages

conda list (current env)
conda list -n <env_name> (from within a different env)
conda list -n <env_name> <pkg_name> (check for a pkg within an env)

Installing packages

conda install <pkg_name>
conda install -c <channel_name> <pkg_name>

Updating packages

conda update <pkg_name>
conda update -c <channel_name> <pkg_name>
conda update --all

Removing packages

conda remove <pkg_name>

Other useful (unsorted) commands

conda env update --prune (update to match yaml env file)
conda init powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Useful arguments

--yes, -y (don't ask for permission)
--display, -d (dry run; useful to try out potentially dangerous actions)
--all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment