Skip to content

Useful Conda Commands

shamik edited this page Apr 25, 2024 · 1 revision

Conda Commands

Installing Miniconda/Mamba in Ubuntu

Miniconda

https://docs.anaconda.com/free/miniconda/miniconda-install/

curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o ~/Downloads/Miniconda3-latest-Linux-x86_64.sh

Mamba

Installation Guide

Installer

curl https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -o ~/Downloads/Miniforge3-Linux-x86_64.sh

Setting automatic base activation to false

conda config --set auto_activate_base false

Create an environment with the latest stable version of python

conda create –n [environment name]

Create an environment with a specific version of python

conda create –n [environment name] python=3.6

Create an environment with default anaconda package set

conda create –n [environment name] anaconda

Listing all the environments

conda env list

Cloning an environment

conda create –n [environment name] --clone [environment name]

Installing a ipykernel for notebooks for the environment named transformers

conda install --name [transformers] ipykernel -y

Installing a package and updating its deps while installation

conda install -n summ_feextract ipykernel --update-deps

Searching a particular version of a package on conda-forge

Sometimes the package name might need to be enclosed in "" If prefixed by *

conda search –c conda-forge streamlit==0.71.0

For Mamba mamba repoquery search –c conda-forge streamlit==0.71.0

Installing packages from requirements.txt

conda install --file requirements.text -c conda-forge –c defaults –c anaconda

Creating an environment from environment.yml

conda env create –f environment.yml

Updating a specific environment from environment.yml

conda env update –n <name of the env> -f environment.yml

Exporting a environment.yml for a specific environment

conda env export --name <envname> > <path/for/environment.yml>

Exporting a environment.yml for an active environment

conda env export > <path/for/environment.yml>

Exporting a requirements.txt for an active environment

pip list --format freeze > <path/for/requirements.txt> 
pip freeze > <path/for/requirements.txt> 
conda list –e > <path/for/requirements.txt> 

Exporting a requirements.txt for a specific environment

conda list –e –n <envname> > <path/for/requirements.txt>

Listing conda config

conda config --show

Adding conda forge as one of the changes to search packages in

conda config --add channels conda-forge Default conda config

Clone this wiki locally