console

Introduction

This document contains frequently used command and the corresponding used cases for package management software Conda. For simplification, all the variables are written in parenthesis, e.g. (package), (version). The optional parameters are written in sqaure brackets, e.g. [—versions], [—mixed]

 

Table of Content

 

Environment Setting

Back to Top

Install Conda package manager (on Linux)

wget https://repo.anaconda.com/archive/Anaconda3-(year).(month)-Linux-x86_64.sh
sh Anaconda3-(year).(month)-Linux-x86_64.sh

Update Conda package manager

conda update conda

Show Conda environments

conda info --envs

Create Conda environment

conda create -n (name) [package A][, package B...]

Switch Conda environment

conda activate (environment)

Return to Conda base environment

conda activate base

Remove Conda environment

conda remove --all -n (environment)

 

Channels

Back to Top

Show all channels Conda has tracked

  • use --env to show only activated environment
conda config [--env] --get channels channel_priority

Disable channel priorities

  • the packages will be installed with the newest version in any listed channel
  • use --env to set only activated environment
conda config [--env] --set channel_priority flexible

Enable channel priorities

  • use --env to set only activated environment
conda config [--env] --set channel_priority strict

Track new channel with the highest priority

  • use --env to set only activated environment
conda config [--env] --prepend channels (channel.url)

Track new channel with the lowest priority

  • use --env to set only activated environment
conda config [--env] --append channels (channel.url)

Removed tracked channel

  • use --env to set only activated environment
conda config [--env] --remove channels (channel)

 

Package Explorer

Back to Top

Show installed packages

conda list -n (environment)

Show outdated packages

conda search --outdated

Search available packages in tracked channels

conda search (package/regex) 

 

Package Installation

Back to Top

Install specific package in the activated environment

conda install (package)[=(version)]

Reinstall specific package in the activated environment

conda install [--force-reinstall] (package)

Uninstall specific package in the activated environment

  • use -n to uninstall the pacakge only in given environment
conda remove [-n (environment)] (package)

 

Upgrade Installed Package

Back to Top

Upgrade specific package in the activated environment

  • use -n to update the pacakge only in given environment
conda update [-n (environment)] [package]

Upgrade all packages except for pinned packages

  • use -n to update the pacakge only in given environment
conda update [-n (environment)] --all

Edit pinned packages

# console
vim $conda-root/conda-meta/pinned

# vim 
[package A==version]
[package B==version]
...

 

Export and Import

Back to Top

Export packages

  • use -n to export the pacakges in given environment
conda list [-n (environment)] --export [> packages.txt]

Import packages

conda install --file (packages.txt)

Create environment with given packages

conda create -n (name) --file (packages.txt)

Related articles

Introduction to Linux

An operating system sits between users and hardware. It manages memory, processes, files, and devices while exposing a graphical or command-line interface. - Linux - iOS - Android - macOS - Windows…

Training

Poetry

This file defines project metadata and dependencies. This file pins the exact dependency versions used in the project for reproducibility. --- --- Poetry is ideal for clean, reproducible Python pro…

Training

Python

In Python, values such as integers, strings, lists, and functions are all objects. They have types and methods, which is different from C++ primitive values. --- Lists are ordered, mutable sequence…

Training

Git

Git is a distributed version control system (DVCS) used to: - track changes to files over time - collaborate with multiple people on the same project - manage branches independently - sync code wit…

Training