Conda

Installation

5 steps:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# create a directory to install minicaonda in
mkdir -p ~/miniconda3

# download latest miniconda version
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh

# run the install script
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3

# delete the intall script
rm -rf ~/miniconda3/miniconda.sh

# add a conda initialize to your bash
~/miniconda3/bin/conda init bash

# Verify the installaton
conda list

Environment & Library

Create a new environment:

1
conda create -n [newevname] python=[YourVersion]

Switch to another environment:

1
conda activate [evname]

conda deactivate will make you exit the current environment and turn back to base environment.

Rename an environment:

1
2
conda create -n [newevname] --clone [oldenvname]
conda remove -n [oldevname] --all

If there are some packages or programs related to the environment name (e.g. jupyter notebook), avoid renaming or copying. Actually, the commands above are clone and remove commands.

Install a new library:

1
conda install [libname]

pip can also be used to install new libraries. Use uninstall to uninstall the library you don't need.

Information

List all installed libraries in the current environment:

1
conda list

List all the virtual environments you have created:

1
conda env list

Sharing

To share your environment with others, you should first export your configuration to a yml file:

1
conda env export > [filename].yml

The yml file will be created in your current folder.

Then, the yml file can be used to create an environment that is the same as yours:

1
conda env create -f [filename].yml

The first line of the yml file is the name of the created environment. You should make sure that the yml file is in your current folder.

Configuration

Create .condarc:

1
conda config --add channels r

Tsinghua mirror and env path:

1
2
3
4
5
6
7
8
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/mro
envs_dirs:
- C://[root of your anaconda/miniconda]//envs

More information