Minimal examples using Conda

28 Oct 2020

Conda

Managing envs

Conda allows to create separated environment setups to code in Python.

Create an env from scratch

To create an env with python version 3.6 run:

    conda create --name <env-name> python=3.6

Create an env from env file

It is possible to recreate an env setup, one will need to have a saved env file. For instance, suppose we have an env file env-file.txt, to recreate the env run:

    conda env create --file  <env-file>.txt 

It is possible to edit the env file to update package’s versions and env’s name

Clone an env

To clone an env run:

    conda create --clone <sourc-env> --name <dest-env> 

Save an env to file

To save an env to file run:

    conda list --explicit >  <env-name>.txt 

Delete an env

    conda env remove --name <env-name>

List existing envs

    conda env list

List installed packages of an env

    conda list --name <env-name>

Source: Conda Cheat Sheet

Installing packages in envs

Using conda

    conda install -c conda-forge <pack> --name <env-name>

Using pip

    <env-path/bin/pip> install <pack>