1. Environment Management Link to heading
Create a virtual environment
conda create -n <env_name> python=<version> # -n specifies the environment name, python= specifies the Python version conda env create -f environment.yml # Create environment based on the environment.yml file
Delete a virtual environment
conda env remove -n <env_name>
Activate/Switch virtual environments
conda activate <env_name> # Activate the virtual environment by name or source activate <env_name>
Deactivate the current virtual environment
conda deactivate
List all virtual environments
conda env list
View current virtual environment information
conda info
Update the environment based on the environment.yml file
conda env update -f environment.yml
Display the list of mirror sources
conda config --show channels
2. Environment Configuration Link to heading
- Export the virtual environment configuration to a .yaml file
conda env export > environment.yaml
- Create a virtual environment using a .yaml file
conda env create -f environment.yaml
- Update a virtual environment using a .yaml file
conda env update -f environment.yaml
3. Package Management Link to heading
- Install a package
conda install package_name # conda install numpy conda install package_name=version # conda install numpy=1.16.0
- Update a package
conda update package_name # conda update numpy
4. Change Source Link to heading
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes # Display the source URL
conda clean -i # Clean index cache