Skip to content

Instantly share code, notes, and snippets.

@chrisbraddock
Created May 2, 2024 18:04
Show Gist options
  • Save chrisbraddock/806d8c2005a68e024130a2d5c660df45 to your computer and use it in GitHub Desktop.
Save chrisbraddock/806d8c2005a68e024130a2d5c660df45 to your computer and use it in GitHub Desktop.
Reset Anaconda / Miniconda Base Environment
# https://stackoverflow.com/a/77768997/227260
CONDA_DIR="$HOME/anaconda3"
CONDA_DIR_BAK="${CONDA_DIR}_bak"
# Miniconda: https://docs.anaconda.com/free/miniconda/miniconda-other-installer-links/
# Anaconda: https://repo.anaconda.com/archive/
CONDA_INSTALL_SHELL="https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh"
# Check if backup directory exists and move if it does not
if [ -d "$CONDA_DIR" ]; then
if [ -d "$CONDA_DIR_BAK" ]; then
echo "Backup directory already exists. Please resolve manually."
exit 1
fi
mv "$CONDA_DIR" "$CONDA_DIR_BAK"
fi
mkdir -p "$CONDA_DIR"
wget "$CONDA_INSTALL_SHELL" -O "$CONDA_DIR/conda.sh"
bash "$CONDA_DIR/conda.sh" -b -u -p "$CONDA_DIR"
rm "$CONDA_DIR/conda.sh"
# Move environments back to the new installation
if [ -d "$CONDA_DIR_BAK/envs" ]; then
mv "$CONDA_DIR_BAK/envs" "$CONDA_DIR"
fi
conda info --envs
echo "If everything is working, remove the backup with: rm -rf $CONDA_DIR_BAK"
@evaneliasyoung
Copy link

evaneliasyoung commented May 4, 2024

Here from Stack Overflow 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment