Created
May 2, 2024 18:04
-
-
Save chrisbraddock/806d8c2005a68e024130a2d5c660df45 to your computer and use it in GitHub Desktop.
Reset Anaconda / Miniconda Base Environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here from Stack Overflow 👍