Conda_가상환경 관리

IT Newbie·2022년 4월 2일
0

Create a new conda environment from a list of specified packages. : Anaconda 새로운 가상환경 생성

conda create --name {Name of environment} python={package_spec : Python Version}

ex) conda create --name env01 python=3.6

  • -n ENVIRONMENT : --name ENVIRONMENT : Name of environment

새로운 가상환경을 활성화하여 확인

conda activate {envname}

ex) conda activate env01

List all known conda environments : Anaconda 가상환경 목록 확인

conda env list
conda info --envs
  • -e : --envs : List all known conda environments.

Remove an environment Removes a provided environment : Anaconda 가상환경 제거

conda env remove -n {Name of environment}
  • -n ENVIRONMENT : --name ENVIRONMENT : Name of environment

Activate a conda environment. : 가상환경 활성화

conda activate {env_name_or_prefix}

ex) conda activate env01

  • env_name_or_prefix : The environment name or prefix to activate.
    If the prefix is a relative path, it must start with './' (or '.\' on Windows).

Deactivate the current active conda environment.

conda deactivate

Change conda env name

conda create --name [변경할이름] --clone [기존환경이름]
  • --clone ENV : Path to (or name of) existing local environment.
conda activate [변경할이름]
conda remove --name [기존환경이름] --all

Package an existing conda environment into an archive file : 환경 내보내기(다른 시스템에서 사용하기)

  1. Build file 로 export 하기 ex) .yml
conda env export -n {Name of environment} -f {name of file}
  • -n ENVIRONMENT : --name ENVIRONMENT : Name of environment
  • -f FILE, --file FILE environment definition file (default: environment.yml)
  1. Build file 로 import 하기 ex) .yml
conda env create -f environment.yml
  • -f FILE, --file FILE environment definition file (default: environment.yml)
  1. Package 로 export 하기 ex) .zip, .tar.gz
conda pack --name {Name of environment} --output {The path of the output file}

ex)
conda pack -n env -o /Users/mac/Downloads/env.zip
conda pack -n my_env -o my_env.tar.gz (현 디렉토리에 저장)

  • --name ENV, -n ENV : The name of the environment to pack.

    If neither --name nor --prefix are supplied, the current activated environment is packed.

  • --output PATH, -o PATH :The path of the output file. Defaults to the environment name with a .tar.gz suffix (e.g. my_env.tar.gz).

환경 가져오기 (M1 MacBookAir 기준)

conda pack으로 압축한 파일을 /Users/mac/opt/anaconda3/envs/{환경이름} 에 압축 해제

0개의 댓글