A 13-minute live demo of this presentation can be found here
Slides can be found and downloaded here:
Conda also has a pdf cheat sheet available.
- Install conda by following the installation instructions here
You will be asked to download a file and run it.
Note:
- I recommend (and use) ‘miniconda’ over ‘anaconda’ because it is more lightweight. Anaconda is a much larger file with many pre-installed packages that you may not need.
- If you are using Windows, I recommend installing WSL (Windows Subsystem for Linux) with Ubuntu and installing conda on it. Instructions for setting up WSL can be found here
- After installing conda, install mamba by running:
conda install mamba -n base -c conda-forge
More information on mamba can be found here.
Never install anything in your 'base' environment (installing mamba is an exception).
By default, after installation, the 'base' environment will always be active when you open a terminal window.
You can change this setting by running the following:
conda config --set auto_activate_base false
Conda install from 'channels'
If you are going to use GPUs, you might want to add the NVIDIA cahnnel and the Rapids.ai channel:
conda config --add channels nvidia
conda config --add channels rapidsai
The most popular, comprehensive, and well-maintained channel is 'conda-forge'
You should make sure to add this channel, and add it last (the '--add' flag also sets the added cahnnel to the highest priority channel; we want conda-forge to be the highest priority channel).
conda config --add channels conda-forge
- To create an environment, use: mamba create
mamba create -n {YOUR-ENV-NAME}
- To activate an environment, use: conda activate
conda activate {YOUR-ENV-NAME}
- To install packages in an active environment, use: mamba install
mamba install {PACKAGE-NAME}
To install packages in a specific (can be not-active) environment, add the '-n' flag, followed by an environment name.
mamba install -n {ANY-ENV-NAME} {PACKAGE-NAME}
You can install packages when creating a new environment, by specifying the package name(s) afterwards.
mamba create -n {YOUR-ENV-NAME} {PACKAGE-NAME-1} {PACKAGE-NAME-2}
You can install a specific package version by adding the '=' sign, followed by the version (no spaces).
mamba create -n {YOUR-ENV-NAME} {PACKAGE-NAME}={VERSION}
mamba install {PACKAGE-NAME}={VERSION}
You can install from a specific channel by using the '-c' flag, followed by the channel.
mamba create -n {YOUR-ENV-NAME} -c {CHANNEL-NAME} {PACKAGE-NAME}
mamba install -c {CHANNEL-NAME} {PACKAGE-NAME}
- To deactivate an environment, use: conda deactivate
conda deactivate
- To view all environment, use: conda env list
conda env list
- To view delete an environment, use: conda env remove
conda env remove -n {YOUR-ENV-NAME}
- To remove packages from an active environment, use: mamba uninstall
mamba uninstall {PACKAGE-NAME}
- To export an active environment, use: mamba env export
mamba env export > {ENV-EXPORT-FILE-NAME}
- To re-create an exported environment, use: mamba env create
mamba env create -f {ENV-EXPORT-FILE-NAME}
- The preferred way of installing is using mamba/conda.
- Sometimes mamba/conda don’t have the package version you need.
- In these cases, you can use pip
However, if you must you pip:
- Use mamba/conda to install everything that you can
- Use pip at the end
By default, when installing mamba/conda packages, the user will be prompted to confirm the installs.
You can skip this confirmation by adding the '-y' flag at the end of an install command:
mamba install {PACKAGE-NAME} -y
It is possible to set environment variables in an activated environment, using the format:
conda env configs vars set {ENV-VAR-NAME}={ENV-VAR-VALUE}
To view variables in an activated environment, run:
conda env configs vars list
To remove environment variables in an activated environment, use this format:
conda env configs vars unset {ENV-VAR-NAME}
Set environment variables will be included in yaml file during exports, and will be set when recreating environments from yaml files.