Linux | Anaconda 설치 및 설정 (Ubuntu)

zerocoke·2024년 1월 16일

Python

목록 보기
1/3
post-thumbnail

서론

클라우드 서비스를 이용하게 되면서 거짓말 안치고 아나콘다 가상환경 설정만 50번 정도 한 것 같다.

이제 그냥 매뉴얼을 만들어 놓고 그대로 복붙만 하면 되는 지경이 되어 공유하기로 했다.

1. 아나콘다 설치

아나콘다 설치파일 다운로드할 경로로 이동

※ 경로 확인 필수

cd <설치 경로>

아나콘다 설치파일 다운로드

wget https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh
  • 아나콘다 최신 버전인지 확인이 필요하나, 어차피 이후에 아나콘다 업데이트 할 거라면 신경 안써도 될 듯.

아나콘다 설치

sh Anaconda3-2023.03-1-Linux-x86_64.sh
# or bash Anaconda3-2023.03-1-Linux-x86_64.sh
  • 이후 설치 프로세스가 진행되는데, 계속 엔터 눌러서 진행하면 됨
  • 다만!!!!!!!!!!!!!!!!!! 엔터가 아닌 yes or no로 답변해야되는 경우가 있음 → yes ⇒ 이때 no가 아닌 yes로 답변해야 conda init을 할 수 있음.
  • 하지만, 실수로 엔터를 눌러버렸다…. "당신은 conda init을 하지 않았습니다" (default가 no로 되어 엔터로 진행시킬 경우 conda init이 되지 않음)
    • 그런 상태로 conda 설치를 마치면 아래와 같은 안내가 이루어 짐
      Do you wish the installer to initialize Anaconda3
      by running conda init? [yes|no]
      [no] >>>
      You have chosen to not have conda modify your shell scripts at all.
      To activate conda's base environment in your current shell session:
      
      eval "$(/home/ryu/anaconda3/bin/conda shell.YOUR_SHELL_NAME hook)"
      
      To install conda's shell functions for easier access, first activate, then:
      
      conda init
      
      If you'd prefer that conda's base environment not be activated on startup,
         set the auto_activate_base parameter to false:
      
      conda config --set auto_activate_base false
      
      Thank you for installing Anaconda3!

1.2. [수동 설정] Conda init (console에서 바로 anaconda 사용하기)

eval "$(<conda 설치한 경로>/anaconda3/bin/conda shell.bash hook)"
  • 이 명령어 입력해 주면 바로 아나콘다 사용 가능 ⇒ 바로 사용 가능이란, 내가 bash 또는 conda actiavte 를 입력했을 때 바로 (base)가 뜨면서 아나콘다 기본 가상환경이 activate 됨을 의미

2. 아나콘다 업데이트

  • conda가 최신 버전이 아닐 경우, 각양 각색의 오류가 발생하기 때문에 최신 버전을 유지해 줘야 함.
    • 자주 발생하는 오류 Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: → 무한 돌기 ※ 위 현상 (아나콘다 가상환경 생성 안됨)의 원인이 이거 하나라고 할 순 없지만, 아나콘다 버전을 업데이트 해주면 어처구니 없게도 해결되는 경우가 종종 있다.
conda update -n base conda
conda update --all

3. Full commands (예시)

cd /home/work/
wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh
sh Anaconda3-2023.03-1-Linux-x86_64.sh
eval "$(/home/work/anaconda3/bin/conda shell.bash hook)"
conda update -n base conda
y

0개의 댓글