Windows在命令行中使用conda命令创建删除虚拟环境
1.查看系统现有的conda环境:conda env list
C:\Users\Administrator>conda env list
# conda environments:
#
base * D:\program files\Anaconda3
C:\Users\Administrator>
2.创建一个名为python37,Python版本为3.7的conda虚拟环境:conda create -n python37 python=3.7
出现下面的情况输入 y(是否安装以下包)
The following NEW packages will be INSTALLED:
ca-certificates pkgs/main/win-64::ca-certificates-2019.10.16-0
certifi pkgs/main/win-64::certifi-2019.9.11-py37_0
openssl pkgs/main/win-64::openssl-1.1.1d-he774522_3
pip pkgs/main/win-64::pip-19.3.1-py37_0
python pkgs/main/win-64::python-3.7.5-h8c8aaf0_0
setuptools pkgs/main/win-64::setuptools-41.6.0-py37_0
sqlite pkgs/main/win-64::sqlite-3.30.1-he774522_0
vc pkgs/main/win-64::vc-14.1-h0510ff6_4
vs2015_runtime pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_0
wheel pkgs/main/win-64::wheel-0.33.6-py37_0
wincertstore pkgs/main/win-64::wincertstore-0.2-py37_0
Proceed ([y]/n)? y
C:\Users\Administrator>conda env list
# conda environments:
#
base * D:\program files\Anaconda3
python37 D:\program files\Anaconda3\envs\python37
C:\Users\Administrator>
3.进入名为python37的环境:activate python37
C:\Users\Administrator>activate python37
(python37) C:\Users\Administrator>
4.搜索想要安装的包的所有版本(使用tensorflow包举例):
(python37) C:\Users\Administrator>conda search tensorflow
Loading channels: done
# Name Version Build Channel
tensorflow 1.7.0 0 pkgs/main
tensorflow 1.7.1 0 pkgs/main
tensorflow 1.8.0 0 pkgs/main
tensorflow 1.9.0 eigen_py35hb0e21f4_1 pkgs/main
tensorflow 1.9.0 eigen_py36h0b764b7_1 pkgs/main
tensorflow 1.9.0 gpu_py35h0075c17_1 pkgs/main
tensorflow 1.9.0 gpu_py36hfdee9c2_1 pkgs/main
tensorflow 1.10.0 eigen_py35h38c8211_0 pkgs/main
tensorflow 1.10.0 eigen_py36h849fbd8_0 pkgs/main
tensorflow 1.10.0 gpu_py35ha5d5ef7_0 pkgs/main
tensorflow 1.10.0 gpu_py36h3514669_0 pkgs/main
tensorflow 1.10.0 mkl_py35h4a0f5c2_0 pkgs/main
tensorflow 1.10.0 mkl_py36hb361250_0 pkgs/main
tensorflow 1.11.0 eigen_py36h346fd36_0 pkgs/main
tensorflow 1.11.0 gpu_py36h5dc63e2_0 pkgs/main
tensorflow 1.11.0 mkl_py36h41bbc20_0 pkgs/main
tensorflow 1.12.0 eigen_py36h67ac661_0 pkgs/main
tensorflow 1.12.0 gpu_py36ha5f9131_0 pkgs/main
tensorflow 1.12.0 mkl_py36h4f00353_0 pkgs/main
tensorflow 1.13.1 eigen_py36hf0a88a9_0 pkgs/main
tensorflow 1.13.1 eigen_py37h2a8d240_0 pkgs/main
tensorflow 1.13.1 gpu_py36h1635174_0 pkgs/main
tensorflow 1.13.1 gpu_py36h9006a92_0 pkgs/main
tensorflow 1.13.1 gpu_py37h83e5d6a_0 pkgs/main
tensorflow 1.13.1 gpu_py37hbc1a9d5_0 pkgs/main
tensorflow 1.13.1 mkl_py36hd212fbe_0 pkgs/main
tensorflow 1.13.1 mkl_py37h9463c59_0 pkgs/main
tensorflow 1.14.0 eigen_py36hf4fd08c_0 pkgs/main
tensorflow 1.14.0 eigen_py37hcf3f253_0 pkgs/main
tensorflow 1.14.0 gpu_py36h305fd99_0 pkgs/main
tensorflow 1.14.0 gpu_py36heb2afb7_0 pkgs/main
tensorflow 1.14.0 gpu_py37h2fabf85_0 pkgs/main
tensorflow 1.14.0 gpu_py37h5512b17_0 pkgs/main
tensorflow 1.14.0 mkl_py36hb88db5b_0 pkgs/main
tensorflow 1.14.0 mkl_py37h7908ca0_0 pkgs/main
tensorflow 2.0.0 eigen_py36h457aea3_0 pkgs/main
tensorflow 2.0.0 eigen_py37hbfc5123_0 pkgs/main
tensorflow 2.0.0 gpu_py36hfdd5754_0 pkgs/main
tensorflow 2.0.0 gpu_py37h57d29ca_0 pkgs/main
tensorflow 2.0.0 mkl_py36h781710d_0 pkgs/main
tensorflow 2.0.0 mkl_py37he1bbcac_0 pkgs/main
(python37) C:\Users\Administrator>
5.安装包的时候不加版本号默认安装包的最新版本:conda install tensorflow
这里安装tensorflow的1.14.0版本:conda install tensorflow==1.14.0
(python37) C:\Users\Administrator>conda install tensorflow==1.14.0
出现下面情况选择 y(是否安装以下包)
The following NEW packages will be INSTALLED:
_tflow_select pkgs/main/win-64::_tflow_select-2.3.0-mkl
absl-py pkgs/main/win-64::absl-py-0.8.0-py37_0
astor pkgs/main/win-64::astor-0.8.0-py37_0
blas pkgs/main/win-64::blas-1.0-mkl
gast pkgs/main/noarch::gast-0.3.2-py_0
grpcio pkgs/main/win-64::grpcio-1.16.1-py37h351948d_1
h5py pkgs/main/win-64::h5py-2.9.0-py37h5e291fa_0
hdf5 pkgs/main/win-64::hdf5-1.10.4-h7ebc959_0
icc_rt pkgs/main/win-64::icc_rt-2019.0.0-h0cc432a_1
intel-openmp pkgs/main/win-64::intel-openmp-2019.4-245
keras-applications pkgs/main/noarch::keras-applications-1.0.8-py_0
keras-preprocessi~ pkgs/main/noarch::keras-preprocessing-1.1.0-py_1
libmklml pkgs/main/win-64::libmklml-2019.0.5-0
libprotobuf pkgs/main/win-64::libprotobuf-3.9.2-h7bd577a_0
markdown pkgs/main/win-64::markdown-3.1.1-py37_0
mkl pkgs/main/win-64::mkl-2019.4-245
mkl-service pkgs/main/win-64::mkl-service-2.3.0-py37hb782905_0
mkl_fft pkgs/main/win-64::mkl_fft-1.0.15-py37h14836fe_0
mkl_random pkgs/main/win-64::mkl_random-1.1.0-py37h675688f_0
numpy pkgs/main/win-64::numpy-1.17.3-py37h4ceb530_0
numpy-base pkgs/main/win-64::numpy-base-1.17.3-py37hc3f5095_0
protobuf pkgs/main/win-64::protobuf-3.9.2-py37h33f27b4_0
pyreadline pkgs/main/win-64::pyreadline-2.1-py37_1
scipy pkgs/main/win-64::scipy-1.3.1-py37h29ff71c_0
six pkgs/main/win-64::six-1.12.0-py37_0
tensorboard pkgs/main/win-64::tensorboard-1.14.0-py37he3c9ec2_0
tensorflow pkgs/main/win-64::tensorflow-1.14.0-mkl_py37h7908ca0_0
tensorflow-base pkgs/main/win-64::tensorflow-base-1.14.0-mkl_py37ha978198_0
tensorflow-estima~ pkgs/main/noarch::tensorflow-estimator-1.14.0-py_0
termcolor pkgs/main/win-64::termcolor-1.1.0-py37_1
werkzeug pkgs/main/noarch::werkzeug-0.16.0-py_0
wrapt pkgs/main/win-64::wrapt-1.11.2-py37he774522_0
zlib pkgs/main/win-64::zlib-1.2.11-h62dcd97_3
Proceed ([y]/n)? y
5.卸载已安装的tensorflow包:conda uninstall tensorflow
(python37) C:\Users\Administrator>conda uninstall tensorflow
6.退出环境:deactivate
(python37) C:\Users\Administrator>deactivate
DeprecationWarning: 'deactivate' is deprecated. Use 'conda deactivate'.
(python37) C:\Users\Administrator>conda.bat deactivate
C:\Users\Administrator>
7.删除环境:conda remove -n python37 --all
C:\Users\Administrator>conda remove -n python37 --all
出现下面情况输入 y(是否确定删除以下包)
The following packages will be REMOVED:
ca-certificates-2019.10.16-0
certifi-2019.9.11-py37_0
openssl-1.1.1d-he774522_3
pip-19.3.1-py37_0
python-3.7.5-h8c8aaf0_0
setuptools-41.6.0-py37_0
sqlite-3.30.1-he774522_0
vc-14.1-h0510ff6_4
vs2015_runtime-14.16.27012-hf0eaf9b_0
wheel-0.33.6-py37_0
wincertstore-0.2-py37_0
Proceed ([y]/n)? y
最后看一下conda的所有环境
C:\Users\Administrator>conda env list
# conda environments:
#
base * D:\program files\Anaconda3
C:\Users\Administrator>
删除成功啦