본문 바로가기
IT

Anaconda를 우분투 리눅스(ubuntu linux)에서 삭제하는 방법

by eddy's warehouse 2024. 2. 13.

python 가상환경 구성을 위해 Anaconda를 사용했었습니다. 패키지 관리가 편리하다고 생각했었는데요, 이제는 그냥 docker에 관리를 하는 것이 낫겠다고 생각하여 Anaconda를 삭제하게 되었습니다. 오늘은 Anaconda를 우분투 리눅스에서 삭제하는 방법을 알아보도록 하겠습니다.

Anaconda를 우분투 리눅스(ubuntu linux)에서 삭제하는 방법 썸네일

1. anaconda-clean 설치

Anaconda를 삭제하는 것은 anaconda-clean을 설치후 해당 명령어로 삭제하게 됩니다.

먼저 conda install을 이용해서 anaconda-clean을 설치합니다. 중간에 Proceed를 물어보면 y를 누르고 엔터를입력합니다.

ubuntu@instance-20230810-1409:~$ conda install anaconda-clean
Collecting package metadata (current_repodata.json): / DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443                                                                                                                      \ DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/r/linux-64/current_repodata.json HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/main/linux-64/current_repodata.json HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/main/noarch/current_repodata.json HTTP/1.1" 200 None                                                                                 | DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/r/noarch/current_repodata.json HTTP/1.1" 200 None                                                                                    done
Solving environment: -
.....
The following NEW packages will be INSTALLED:

  anaconda-clean     pkgs/main/linux-64::anaconda-clean-1.1.1-py311h06a4308_0

The following packages will be UPDATED:

  ca-certificates                     2023.05.30-h06a4308_0 --> 2023.12.12-h06a4308_0
  certifi                         2023.7.22-py311h06a4308_0 --> 2024.2.2-py311h06a4308_0
  conda-content-tru~ pkgs/main/noarch::conda-content-trust~ --> pkgs/main/linux-64::conda-content-trust-0.2.0-py311h06a4308_0
  openssl                                 1.1.1u-h7f8727e_0 --> 1.1.1w-h7f8727e_0


Proceed ([y]/n)? y
...
DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/main/linux-64/conda-content-trust-0.2.0-py311h06a4308_0.conda HTTP/1.1" 200 62842                                               |  19%

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

 

2. anaconda-clean으로 삭제하기

anaconda-clean이 설치되면 아래 명령을 수행하여 anaconda를 삭제합니다.

ubuntu@instance-20230810-1409:~$ anaconda3/bin/anaconda-clean --yes
Backup directory: /home/ubuntu/.anaconda_backup/2024-02-13T081452

ubuntu@instance-20230810-1409:~$ rm -rf anaconda3/ .anaconda_backup/

 

3. bashrc 수정하기

위와 같이 관련 데이터를 모두 삭제 한 후에 bashrc에 conda 관련 초기화 내용을 제거해 줍니다.

bashrc 파일은 두 가지가 있을 수 있는데, 저의 경우에는 ~/.bashrc만 관련 내용이 있어서 해당 내용만 초기화 하였습니다.

파일은 /etc/bash.bashrc 파일과 ~/.bashrc 두 개의 파일을 확인해 보시면 됩니다.

다음과 같이 되어있는 라인을 삭제합니다.

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

 

오늘은 conda 환경을 삭제하는 방법에 대해서 알아보았습니다.

facebook twitter kakaoTalk kakaostory naver band shareLink