logo

Collection of Conda Commands 📂Programing

Collection of Conda Commands

Overview

This document summarizes the commands used with conda.

Code

Virtual environment management

These are the most basic commands for creating and switching virtual environments.

  • Create environment: conda create -n [environment_name] python=[version]
  • Activate environment: conda activate [environment_name]
  • Deactivate environment: conda deactivate
  • List environments: conda env list or conda info –envs
  • Remove environment: conda env remove -n [environment_name]
  • Clone environment: conda create -n [new_name] –clone [existing_name]

Package installation and management

Used to install and manage libraries required within a virtual environment.

  • Install package: conda install [package_name]
    • Install a specific version: conda install [package_name]=[version]
  • Remove package: conda remove [package_name]
  • Update package: conda update [package_name]
    • Update all: conda update –all
  • List installed packages (in the current environment): conda list
    • (For a specific environment): conda list -n [environment_name]
  • Search for packages: conda search [package_name]

Note that when specifying versions, pip uses two equals signs (==) while conda uses one (=).

pip install [패키지명]==[버전]

conda install [패키지명]=[버전]

Exporting and restoring environments

A way to transfer the current environment configuration intact when collaborating or migrating servers.

  • Save environment configuration (YAML): conda env export > environment.yaml
    • Save only Python packages: pip freeze > requirements.txt
  • Create environment from YAML: conda env create -f environment.yaml

System management and miscellaneous

  • Check Conda information: conda info
    • Check Conda version: conda –version
  • Update Conda itself: conda update conda
  • Clear cache (to free space): conda clean –all
  • Run in a specific environment: conda run -n [environment_name] python [file_name]