1. Create / Delete environment
# 查看环境
conda info --e
# 创建环境(xxx 表示环境名称)
conda create -n xxx python=2.7
# 激活环境
source activate xxx
# 切换到base环境
activate
# 退出环境
source deactivate xxx
# 删除环境
conda remove -n xxx --all
# 安装包
conda install package
pip install package
# 查看当前环境已安装包
conda list
# 更新包
conda update package
# 更新环境xxx的名为packagename的包
conda update -n [xxx] [packagename]
# 移除包
conda remove package
pip uninstall package
# 删除learn环境及下属所有包
conda remove -n xxx --all
2. Copy the environment
2.1. The machine copy
conda create -n new_env --clone old_env
2.2. Non-native replication
# 导出环境
conda env export > environment.yaml
# 在新的机器上安装环境
conda env create -f environment.yaml
Use conda env export
command to export a yaml file format, the file name records the environment, the software source address, and a list of installed packages, in order to achieve reproducible installation environment.
Note: yaml transplant environment can only be installed with the conda install
command to install the package, if a useful pip install
command to install the package, you need pip freeze
to generate txt file, the same principles and yaml file.
# 导出环境
pip freeze > requirements.txt
# 在新的机器上安装环境
pip install -r requirements.txt
If you want to migrate to another computer without networking, Anaconda if the same version, can directly evns
copy the file corresponding to the file to a location environment.