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
- Channels
- Package Explorer
- Package Installation
- Upgrade Installed Package
- Export and Import
Environment Setting
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
Show all channels Conda has tracked
- use
--envto 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
--envto set only activated environment
conda config [--env] --set channel_priority flexible
Enable channel priorities
- use
--envto set only activated environment
conda config [--env] --set channel_priority strict
Track new channel with the highest priority
- use
--envto set only activated environment
conda config [--env] --prepend channels (channel.url)
Track new channel with the lowest priority
- use
--envto set only activated environment
conda config [--env] --append channels (channel.url)
Removed tracked channel
- use
--envto set only activated environment
conda config [--env] --remove channels (channel)
Package Explorer
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
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
-nto uninstall the pacakge only in given environment
conda remove [-n (environment)] (package)
Upgrade Installed Package
Upgrade specific package in the activated environment
- use
-nto update the pacakge only in given environment
conda update [-n (environment)] [package]
Upgrade all packages except for pinned packages
- use
-nto 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
Export packages
- use
-nto 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)