Python Environments
Install a env manager micromamba/anaconda/etc...
Currently only in micromamba I will add tabs as needed.
https://mamba.readthedocs.io/en/latest/micromamba-installation.html
Create env
Run Env
Add package
Parsisting the envirnoment:
Lets outo activate/deactivate/install the env when changing directories
Add this to the ~/.zshrc file (or adapt to your shell)
auto_activate_micromamba_env() {
if [[ -f "environment.yml" ]]; then
local env_name=$(grep 'name:' environment.yml | awk '{print $2}')
if [[ ! -z "$env_name" ]]; then
# Check if the environment exists
if [[ $(micromamba env list | awk '{print $1}' | grep -w "^${env_name}$") == "" ]]; then
micromamba env create -f environment.yml
fi
# Activate the environment
micromamba activate $env_name
fi
else
# Optionally, deactivate if no environment.yml is found
micromamba deactivate
fi
}
# Add the function to the array of precmds like changing directory
chpwd_functions+=("auto_activate_micromamba_env")
# Activate the environment when spawning a new shell
auto_activate_micromamba_env