Rules / SOPs:
- Don't work in
base
environment - Use
mamba
as a solver - Create default environments with pinned packages, and clone / update the default envs as needed
-
Create env
CONDA_SUBDIR=osx-arm64 conda create -n <env_name> python=3.9
Allowed
CONDA_SUBDIR
architectures include: linux-64, linux-aarch64, linux-ppc64le, osx-64, osx-arm64, win-32, win-64 -
Activate env
conda activate <env_name>
-
Set architecture Allowed
CONDA_SUBDIR
architectures include: linux-64, linux-aarch64, linux-ppc64le, osx-64, osx-arm64, win-32, win-64conda env config vars set CONDA_SUBDIR=osx-arm64 --name <env_name>
-
Set channels
# add to top of list conda config --prepend channels conda-forge # add to end of list conda config --append channels intel
-
Pin package versions (if known in advance)
touch $CONDA_PREFIX/conda-meta/pinned cat << EOF >> $CONDA_PREFIX/conda-meta/pinned python 3.9.* numpy 1.24.* scikit-learn 1.0.* EOF
-
Install packages
-
manually
mamba install -n <env_name> pandas scipy scikit-learn statsmodels jupyterlab
-
from environment.yaml
mamba env update -n <env_name> -f /path/to/environment.yaml
see sample environment.yaml below
-
Create env function (see conda_env_create.sh
below) and load:
zsh ./conda_env_create.sh
Assuming environment.yaml
exists with the CONDA_SUBDIR set:
env_name=...
conda_env_create "$env_name" python=3.9
# env is created and activated
# pin dependencies
touch $CONDA_PREFIX/conda-meta/pinned
cat << EOF >> $CONDA_PREFIX/conda-meta/pinned
python 3.9.*
numpy 1.21.*
EOF
# install packages
mamba env update -n "$env_name" -f /path/to/environment.yaml
# install pip packages
pip install --upgrade-strategy only-if-needed -r /path/to/requirements.txt
pip install --upgrade-strategy only-if-needed --index-url=https://<private_pip_url> -r /path/to/private-requirements.txt
unset env_name
conda create --name clone_env --clone source_env