1. Conda common commands
1. Virtual Environment Management
# 查看现有的环境
$ conda info --env
# 创建环境,后面的python=3.6是指定python的版本
$ conda create --name env_name python=3.6
# 创建包含某些包的环境(也可以加上版本信息)
$ conda create --name env_name python=3.7 numpy scrapy
# 激活某个环境
$ activate env_name
# 关闭某个环境
$ conda deactivate
# 复制某个环境
$ conda create --name new_env_name --clone old_env_name
# 删除某个环境
$ conda remove --name env_name --all
# 生成需要分享环境的yml文件(需要在虚拟环境中执行)
$ conda env export > environment.yml
# 别人在自己本地使用yml文件创建虚拟环境
$ conda env create -f environment.yml
2. Package management
# 列出当前环境下所有安装的 conda 包。
$ conda list
# 列举一个指定环境下的所有包
$ conda list -n env_name
# 查询库
$ conda search scrapys
# 安装库安装时可以指定版本例如:(scrapy=1.5.0)
$ conda install scrapy
# 为指定环境安装某个包
$ conda install --name target_env_name package_name
# 更新安装的库
$ conda update scrapy
# 更新指定环境某个包
$ conda update -n target_env_name package_name
# 更新所有包
$ conda update --all
# 删除已经安装的库也尅用(conda uninstall)
$ conda remove scrapy
# 删除指定环境某个包
$ conda remove -n target_env_name package_name
# 删除没有用的包
$ conda clean -p
2. Conda installation under Linux
1. Download the Anaconda installation package
Tsinghua mirror
in ubuntu ctr+alt+t to open the terminal, enter
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh
You can directly download the anaconda installation package from the mirror website of Tsinghua University, and choose your own version according to the situation. I chose version 2021.11.
2. After the installation package is downloaded, type
bash Anaconda3-2021.11-Linux-x86_64.sh
During the period, where there is ENTER, you can directly press Enter. When you encounter MORE information, you can press the Q key to skip it. When you encounter a place where you need to enter yes|no, enter yes.
3. After the installation is complete, modify the environment variables in the terminal, type
gedit ~/.bashrc
Type in the bottom of the pop-up text box
export PATH="/home/usrname/anaconda3/bin:$PATH"
usrname corresponds to the account name, here you need to modify it according to your own machine, and then click SAVE to save the modification.
source ~/.bashrc
4. Type
conda --version
If there is a version output, the installation is successful.