1 创建环境
# app @ user1 in ~ [13:46:26]
$ conda create -n python3.5_env 【或者指定python版本 conda create -n snakes python=3.7】
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /Users/app/anaconda3/envs/python3.5_env ->【环境位置】
2 列出所有环境
# app @ user1 in ~ [13:53:25]
$ conda info -e
# conda environments:
base * /Users/app/anaconda3
python3.5_env /Users/app/anaconda3/envs/python3.5_env
3 激活环境
# app @ user1 in ~ [13:56:55]
$ source activate python3.5_env
(python3.5_env)
# app @ user1 in ~ [13:58:02]
$ conda info -e
# conda environments:
base /Users/app/anaconda3
python3.5_env * /Users/app/anaconda3/envs/python3.5_env ->【当前环境】
$ conda list 可以看见刚创建的环境,还没有安装各种包
# packages in environment at /Users/app/anaconda3/envs/python3.5_env:
#
# Name Version Build Channel
4 安装另一版本python
conda install python=3.5 【或指定环境 conda install -n python3.5_env python=3.5】
5 移除包
若不指定虚拟环境,默认删除当前环境的包
conda remove [-n python3.5_env] pandas
6 关闭&删除环境
# app @ user1 in ~ [15:04:08] 关闭环境
$ conda deactivate 【有的Mac终端是这个关闭命令:source deactivate】
# app @ user1 in ~ [15:04:30] 查看环境
$ conda info -e
# conda environments:
#
base * /Users/app/anaconda3
python3.5_env /Users/app/anaconda3/envs/python3.5_env
# app @ user1 in ~ [15:05:40] 删除环境
$conda remove -n 3.5_env --all