1. Installation
Please refer to the official docs.
After installing it, we can set mirrors which facilitate download speed in China. It’s recommended to add some mirror configs (Run in command line):
1 2 3
| conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes
|
2. Common commands
2.1 Create env
Create an environment with <env_name>
and python with 3.9
.
1
| conda create -n <env_name> python=3.9
|
2.2 Activate env
Activate / Deactivate the environment <env_name>
.
1 2 3 4
| conda activate <env_name>
conda deactivate <env_name>
|
2.3 Remove env
Remove the environment <env_name>
.
1
| conda remove -n <env_name> --all
|
2.4 Clone env
Clone an existing environment, to a new one. So you don’t need to install package one by one. This command is a variant of conda create
.
1
| conda create -n <new_name> --clone <old_name>
|
2.5 Install packages
1 2 3 4 5 6
| conda install <packages>
pip install <packages>
pip install <packages> -i https://pypi.tuna.tsinghua.edu.cn/simple
|
2.6 Update packages
To update all packages, use:
2.7 List packages in env
2.8 List all envs
2.9 Clean caches
The downloaded caches occupies the storage data. We may clean them by the following commands:
2.10 Export / Import env configs
Export the current environment configs to a yaml file, then we can follow the yaml file to create another environment.
1 2 3 4 5 6 7 8
| conda activate <env_name>
conda env export > environment.yml
conda env create -f environment.yml
|