Macho000

1. 現在の環境を確認

1.1. Anaconda3のホームディレクトリの確認

$ env | grep CONDA
CONDA_SHLVL=2
CONDA_PROMPT_MODIFIER=(GBTI) 
CONDA_EXE=/opt/anaconda3/bin/conda
_CE_CONDA=
CONDA_PREFIX_1=/opt/anaconda3
CONDA_PREFIX=/opt/anaconda3/envs/GBTI
CONDA_PYTHON_EXE=/opt/anaconda3/bin/python
CONDA_DEFAULT_ENV=GBTI

1.2. AnacondaへのPathの確認

$ cat ~/.bash_profile

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

2. anaconda-cleanを実行する

conda install anaconda-clean
anaconda-clean
$ anaconda-clean
Delete .anaconda? (y/n): y
Backup directory: /Users/kosukeaigo/.anaconda_backup/2022-09-05T224138
Delete .conda? (y/n): y
Delete .condarc? (y/n): y
Delete .ipynb_checkpoints? (y/n): y
Delete .ipython? (y/n): y
Delete .jupyter? (y/n): y
Delete .matplotlib? (y/n): y

削除した際にバックアップディレクトリが~/.anaconda_backupに作成される

もし不要な場合は下記のコマンドで削除する

rm -fr /anaconda3

3. .bash_profile中のPathを追加する記述を削除する

echo $SHELL

で、bashが表示された場合は

vi ~/.bash_profile

で下記のconda initializeで囲まれた部分を削除する

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

4. 参考文献

https://weblabo.oscasierra.net/python-anaconda-uninstall-macos/

#Python