使用miniconda创建python虚拟环境

时间:2023-12-15 18:04:32

安装python指定环境

conda create -n oldboy python=3.6.5

安装环境的同时安装相应的包

conda create -n oldboy python=3.6.5 pandas

进入指定的环境

activate oldboy

退出当前环境

deactivate oldboy

显示所有的环境

conda env list

# conda environments:
#
base * D:\miniconda3
PCC D:\miniconda3\envs\PCC
TDD D:\miniconda3\envs\TDD
Web_Spider D:\miniconda3\envs\Web_Spider
oldBoy18 D:\miniconda3\envs\oldBoy18
oldboy D:\miniconda3\envs\oldboy

删除指定的环境

conda env remove -n oldBoy18

Remove all packages in environment D:\miniconda3\envs\oldBoy18:

## Package Plan ##

  environment location: D:\miniconda3\envs\oldBoy18

The following packages will be REMOVED:

    certifi:        2016.2.28-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pip: 9.0.1-py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
python: 3.6.2-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
setuptools: 36.4.0-py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
vc: 14-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
vs2015_runtime: 14.0.25420-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
wheel: 0.29.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
wincertstore: 0.2-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free Proceed ([y]/n)? y

导出当前环境的package信息

conda env export > environment.yaml

environment.yaml

name: oldboy
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
dependencies:
- python=3.6.5=h0c2934d_0
- certifi=2016.2.28=py36_0
- pip=9.0.1=py36_1
- setuptools=36.4.0=py36_1
- vc=14=0
- vs2015_runtime=14.0.25420=0
- wheel=0.29.0=py36_0
- wincertstore=0.2=py36_0
prefix: D:\miniconda3\envs\oldboy

导入他人的开发环境

conda env create -f environment.yaml