Comprehensive list of commonly used anaconda commands (recommended collection for nanny level)

1. Create a virtual environment

conda  create  --name  env_name
conda  create  --name  env_name python=3.6 # 创建指定python版本
conda  create  --name  env_name python=3.6 pandas numpy scipy # 创建指定python版本下包含某些包

2. Activate/use/enter a virtual environment

activate  env_name

3. Exit the current environment

deactivate

4. Copy a virtual environment

conda  create  --name  new_env_name  --clone  old_env_name

5. Delete an environment

conda  remove  --name  env_name  --all

6. View all current environments

conda  info  --envs   或者  conda  env  list

7. View all installation packages in the current virtual environment

conda  list  需进入该虚拟环境
conda  list  -n  env_name

8. Install or uninstall the package (after entering the virtual environment)

conda  install  requests
conda  install  xx=版本号  # 指定版本号
conda  install  xxx -i 源名称或链接 # 指定下载源
conda  uninstall  xxx

9. Share virtual environment

conda env export > environment.yml  # 导出当前虚拟环境
conda env create -f environment.yml  # 创建保存的虚拟环境

10. Source server management

The current source settings of conda are in $HOME/.condarc, which can be viewed through a text viewer or using the command >conda config --show-sources.

conda config --show-sources #查看当前使用源
conda config --remove channels 源名称或链接 #删除指定源
conda config --add channels 源名称或链接 #添加指定源

For example:

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/conda-forge/

Domestic pip source

Alibaba Cloud http://mirrors.aliyun.com/pypi/simple/

University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/

Douban http://pypi.douban.com/simple/

Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/

University of Science and Technology of China http://pypi.mirrors.ustc.edu.cn/simple/

11. Upgrade

To upgrade Anaconda, you need to upgrade conda first.

conda  update  conda
conda  update  anaconda

12. Uninstall

rm  -rf  anaconda

13. Export all components in the virtual environment in batches

conda list -e > requirements.txt  # 导出
conda install --yes --file requirements.txt  # 安装

14. pip batch exports all components in the environment

pip freeze > requirements.txt
pip install -r requirements.txt

I hope it will be helpful to bloggers. It is recommended to save it for later use. Please correct me if there are any mistakes.

It’s not easy for the author to sort it out. Please give me a thumbs up and a follow

Guess you like

Origin blog.csdn.net/m0_64892604/article/details/128806043
Recommended