C.W.K.
Stream
Lesson 03 of 05 · published

매일 치는 conda 명령

~13 min · conda, commands, envs, workflow

Level 0초심자
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

conda 의 CLI 가 환경 관리패키지 관리에서 분리. 둘 다 active 환경 중심.

환경. conda create --name myenv python=3.12 가 Python 3.12 의 새 env 생성. conda activate myenv 가 shell 을 거기로 전환 (prompt 가 (myenv) 접두). conda deactivate 가 종료. conda env list 가 모든 env 표시. conda remove --name myenv --all 이 하나 완전 삭제.

패키지. conda install <pkg> 가 active env 에 install. conda install -c conda-forge <pkg> 가 이 install 에 특정 channel 사용. conda update --all 이 env 의 모든 패키지 업그레이드. conda list 가 깐 패키지 표시. conda remove <pkg> 가 uninstall.

재현성. conda env export > environment.yml 이 env 를 YAML 로 export. conda env create -f environment.yml 이 다른 머신에서 재생성. conda env update -f environment.yml 이 기존 env 에 새 변경 적용.

Code

환경 라이프사이클·bash
# 생성
conda create --name dl python=3.12

# 활성화
conda activate dl
# prompt 가 (dl) 됨

# 사용
conda install pytorch torchvision -c pytorch -c conda-forge
conda install jupyterlab pandas matplotlib

# 뭐 깔렸나
conda list

# 떠나기
conda deactivate

# 모든 env 목록
conda env list
#   base                  /Users/you/miniconda3
# * dl                    /Users/you/miniconda3/envs/dl
#   web                   /Users/you/miniconda3/envs/web

# 삭제
conda remove --name dl --all
재현 가능 env 파일·bash
# 현재 env export
conda env export > environment.yml

# 또는 명시 install 한 것만 export (공유에 더 깔끔)
conda env export --from-history > environment.yml

# 다른 머신에서 재생성
conda env create -f environment.yml

# 변경된 environment.yml 에서 기존 env 업데이트
conda env update -f environment.yml --prune
--from-history 언제 쓰나·yaml
# --from-history 없이 (전체 export — 모든 transitive dep)
name: dl
channels:
  - conda-forge
  - pytorch
dependencies:
  - python=3.12.4=h99cad12_0    # 정확한 빌드 hash
  - pytorch=2.4.0=py3.12_0
  - numpy=1.26.4=py312h7f4f0e0_0
  # ... 200+ 더, 다 빌드 hash 와 함께

# --from-history 와 함께 (너가 install 한 것만)
name: dl
channels:
  - conda-forge
  - pytorch
dependencies:
  - python=3.12
  - pytorch
  - jupyterlab
  - pandas
  - matplotlib
# 플랫폼 간 공유에 더 깔끔; conda 가 타겟 머신에서 다시 resolve.

External links

Exercise

fresh env 생성: 'conda create --name scratch python=3.12 && conda activate scratch && conda install -c conda-forge numpy pandas jupyterlab'. 그 다음 'conda env export --from-history > /tmp/env.yml' 하고 읽어. --from-history 버전이 repo 에 'environment.yml' 로 commit 할 거.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.