Anaconda------环境管理

Anaconda 中的Conda核心功能就是包管理和环境管理,可以根据需要安装不同版本的python,而且能自由切换。

先着重介绍一个概念--虚拟环境(virtual environment),

它是一个虚拟化,从电脑独立开辟出来的环境。以Docker为例,在Docker世界里,虚拟环境就是借助docker来把一部分内容独立出来,我们把这部分独立出来的东西称作“容器”,在这个容器中,我们可以只安装我们需要的依赖包,各个容器之间互相隔离,互不影响。比如,我们需要用到Django,可以做一个Django的虚拟环境,里面只需要安装Django相关包就可以了,当需要Scrapy时,可以创建Scrapy的虚拟环境,里面只需要安装Scrapy相关包。

其实我个人认为虚拟环境这个概念中的“虚拟”一词并不准确,可能用子环境这个词比较贴切一些,虽然说是虚拟环境,但是需要安装的包还是要真实的安装,就像一个Centos虚拟机本质上还是一个Centos系统,只是借助于VirtualBox容器来运行一样,Anaconda中的每个定义的虚拟环境都有一个确定的磁盘位置,在这里就体现为一个具体的目录,比如我的虚拟环境都在/usr/lib64/anaconda3/envs目录下,环境的名字就是目录的名字,各个虚拟环境里需要的相关包也是在各自的目录下。

另外在实际工作中,不同的项目可能使用相同的组件但是版本不同,比如airflow1.x和airflow2.x,或者是某些项目需要运行在python2.7,另一些项目需要3.6,等等诸如此类和版本有关的事务,可以解决anaconda的环境管理都可以一一解决掉。


1. 创建新环境

下面就创建一个名为python36的新环境,并且指定python版本是3.6 不用管是3.6.x,conda会为我们自动寻找3.6.x中的最新版本。

conda create --name python36 python=3.6

下面是详细的安装过程 :

Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.5.4
  latest version: 4.10.3

Please update conda by running

    $ conda update -n base conda





## Package Plan ##

  environment location: /usr/lib64/anaconda3/envs/python36

  added / updated specs: 
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _libgcc_mutex-0.1          |             main           3 KB
    wheel-0.37.0               |     pyhd3eb1b0_1          31 KB
    libgcc-ng-9.1.0            |       hdf63c60_0         8.1 MB
    libstdcxx-ng-9.1.0         |       hdf63c60_0         4.0 MB
    xz-5.2.5                   |       h7b6447c_0         438 KB
    zlib-1.2.11                |       h7b6447c_3         120 KB
    python-3.6.13              |       h12debd9_1        32.5 MB
    readline-8.1               |       h27cfd23_0         464 KB
    openssl-1.1.1l             |       h7f8727e_0         3.8 MB
    certifi-2021.5.30          |   py36h06a4308_0         141 KB
    setuptools-58.0.4          |   py36h06a4308_0         979 KB
    pip-21.2.2                 |   py36h06a4308_0         2.1 MB
    ld_impl_linux-64-2.35.1    |       h7274673_9         637 KB
    ncurses-6.2                |       he6710b0_1         1.1 MB
    sqlite-3.36.0              |       hc218d9a_0         1.4 MB
    ca-certificates-2021.9.30  |       h06a4308_1         123 KB
    libffi-3.3                 |       he6710b0_2          54 KB
    tk-8.6.11                  |       h1ccaba5_0         3.2 MB
    ------------------------------------------------------------
                                           Total:        59.2 MB

The following NEW packages will be INSTALLED:

    _libgcc_mutex:    0.1-main                
    ca-certificates:  2021.9.30-h06a4308_1    
    certifi:          2021.5.30-py36h06a4308_0
    ld_impl_linux-64: 2.35.1-h7274673_9       
    libffi:           3.3-he6710b0_2          
    libgcc-ng:        9.1.0-hdf63c60_0        
    libstdcxx-ng:     9.1.0-hdf63c60_0        
    ncurses:          6.2-he6710b0_1          
    openssl:          1.1.1l-h7f8727e_0       
    pip:              21.2.2-py36h06a4308_0   
    python:           3.6.13-h12debd9_1       
    readline:         8.1-h27cfd23_0          
    setuptools:       58.0.4-py36h06a4308_0   
    sqlite:           3.36.0-hc218d9a_0       
    tk:               8.6.11-h1ccaba5_0       
    wheel:            0.37.0-pyhd3eb1b0_1     
    xz:               5.2.5-h7b6447c_0        
    zlib:             1.2.11-h7b6447c_3       

Proceed ([y]/n)? 

Downloading and Extracting Packages
_libgcc_mutex-0.1    |    3 KB | ############################################################################## | 100% 
wheel-0.37.0         |   31 KB | ############################################################################## | 100% 
libgcc-ng-9.1.0      |  8.1 MB | ############################################################################## | 100% 
libstdcxx-ng-9.1.0   |  4.0 MB | ############################################################################## | 100% 
xz-5.2.5             |  438 KB | ############################################################################## | 100% 
zlib-1.2.11          |  120 KB | ############################################################################## | 100% 
python-3.6.13        | 32.5 MB | ############################################################################## | 100% 
readline-8.1         |  464 KB | ############################################################################## | 100% 
openssl-1.1.1l       |  3.8 MB | ############################################################################## | 100% 
certifi-2021.5.30    |  141 KB | ############################################################################## | 100% 
setuptools-58.0.4    |  979 KB | ############################################################################## | 100% 
pip-21.2.2           |  2.1 MB | ############################################################################## | 100% 
ld_impl_linux-64-2.3 |  637 KB | ############################################################################## | 100% 
ncurses-6.2          |  1.1 MB | ############################################################################## | 100% 
sqlite-3.36.0        |  1.4 MB | ############################################################################## | 100% 
ca-certificates-2021 |  123 KB | ############################################################################## | 100% 
libffi-3.3           |   54 KB | ############################################################################## | 100% 
tk-8.6.11            |  3.2 MB | ############################################################################## | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > source activate python36
#
# To deactivate an active environment, use:
# > source deactivate
#

[root@localhost backup]# 
[root@localhost backup]# 

这个名为python36的新环境位置是/usr/lib64/anaconda3/envs/python36
并且列出将要下载的相关包的名称和大小,这里active environment显示为Node,表示目前还没有及活动的环境,如果激活了某个环境然后执行conda info 这里会显示出环境的名称。
这里安装的速度比较快是因为之前安装Anaconda时设置了Anaconda仓库的镜像,因为Anaconda.org的服务器在国外,所以需要安装packages时,会发现conda下载的速度经常很慢,幸亏清华TUNA镜像源有Anaconda仓库的镜像,需要将其加入conda的配置即可。

# 添加Anaconda的TUNA镜像
conda config --add channels https : //mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

2. 查看conda环境
  

  conda info
 下面是没有进入python36这个小环境之前看到的信息

[root@localhost backup]# conda info
     active environment : None
       user config file : /root/.condarc
 populated config files : /root/.condarc
          conda version : 4.5.4
    conda-build version : 3.10.5
         python version : 3.6.5.final.0
       base environment : /usr/lib64/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /usr/lib64/anaconda3/pkgs
                          /root/.conda/pkgs
       envs directories : /usr/lib64/anaconda3/envs
                          /root/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.4 requests/2.18.4 CPython/3.6.5 Linux/3.10.0-327.el7.x86_64 centos/7 glibc/2.17
                UID:GID : 0:0
             netrc file : None
           offline mode : False

[root@localhost backup]#

这个命令会详细列出conda的所有环境信息,可以看到创建的新环境处于/usr/lib64/anaconda3/envs/,其实用ls 也能查看到这个目录
 

[root@localhost backup]# ls /usr/lib64/anaconda3/envs/
python36

 如果只是用来查看新建的环境,可以使用conda info --even 或者conda -e

[root@localhost backup]# conda info --envs
# conda environments:
#
base                  *  /usr/lib64/anaconda3
python36                 /usr/lib64/anaconda3/envs/python36

[root@localhost backup]# conda info -e
# conda environments:
#
base                  *  /usr/lib64/anaconda3
python36                 /usr/lib64/anaconda3/envs/python36

[root@localhost backup]# 

base表示conda基础的默认环境,python36是刚才新建的环境。

3. 激活指定的环境

在linux下,激活环境使用source active xxxxxx,如果是在windows则使用active xxxxxx

[root@localhost backup]# source activate python36
(python36) [root@localhost backup]# ll
total 636472
-rwxr-xr-x. 1 root root 651745206 Oct 13 04:44 Anaconda3-5.2.0-Linux-x86_64.sh
(python36) [root@localhost backup]# 

上面已经激活了python36这个环境,(python36)显示了当前的环境名称,我们验证一下这个环境的情况:

(python36) [root@localhost backup]# python
Python 3.6.13 |Anaconda, Inc.| (default, Jun  4 2021, 14:25:59) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

可以看到这个环境中的python的版本是3.6.13,第1部分创建环境时,下载了新的python,版本就是python-3.6.13。

在看看pip的版本情况:

(python36) [root@localhost backup]# pip --version
pip 21.2.2 from /usr/lib64/anaconda3/envs/python36/lib/python3.6/site-packages/pip (python 3.6)
(python36) [root@localhost backup]# 

这里的版本是pip 21.2.2,也是新环境中的版本,如果安装了新的包那么就会处于python36这个先环境下面。

此时再查看环境
 

(python36) [root@localhost envs]# conda info

     active environment : python36
    active env location : /usr/lib64/anaconda3/envs/python36
            shell level : 1
       user config file : /root/.condarc
 populated config files : /root/.condarc
          conda version : 4.5.4
    conda-build version : 3.10.5
         python version : 3.6.5.final.0
       base environment : /usr/lib64/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /usr/lib64/anaconda3/pkgs
                          /root/.conda/pkgs
       envs directories : /usr/lib64/anaconda3/envs
                          /root/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.4 requests/2.18.4 CPython/3.6.5 Linux/3.10.0-327.el7.x86_64 centos/7 glibc/2.17
                UID:GID : 0:0
             netrc file : None
           offline mode : False

(python36) [root@localhost envs]# 

可以看到 active environment : python36,表示当前激活的环境是python36


4. 退出当前的环境

conda deactivate
 

(python36) [root@localhost backup]# conda deactivate
[root@localhost backup]# pip --version
pip 10.0.1 from /usr/lib64/anaconda3/lib/python3.6/site-packages/pip (python 3.6)
[root@localhost backup]# 

退出python36环境之后查看外面的pip版本,可以看到版本是10.0.1,说明外面环境下的pip版本确实比新环境python36下的版本低好多,由此可以看出环境管理的的意义非凡。

5. 列出指定环境下安装的包
 

命令:conda list
这个命令本身就是列出conda中安装的包,只是在指定的小环境中可以列出当前环境下安装的包。
 

(python36) [root@localhost backup]# conda list
# packages in environment at /usr/lib64/anaconda3/envs/python36:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main    defaults
ca-certificates           2021.9.30            h06a4308_1    defaults
certifi                   2021.5.30        py36h06a4308_0    defaults
ld_impl_linux-64          2.35.1               h7274673_9    defaults
libffi                    3.3                  he6710b0_2    defaults
libgcc-ng                 9.1.0                hdf63c60_0    defaults
libstdcxx-ng              9.1.0                hdf63c60_0    defaults
ncurses                   6.2                  he6710b0_1    defaults
openssl                   1.1.1l               h7f8727e_0    defaults
pip                       21.2.2           py36h06a4308_0    defaults
python                    3.6.13               h12debd9_1    defaults
readline                  8.1                  h27cfd23_0    defaults
setuptools                58.0.4           py36h06a4308_0    defaults
sqlite                    3.36.0               hc218d9a_0    defaults
tk                        8.6.11               h1ccaba5_0    defaults
wheel                     0.37.0             pyhd3eb1b0_1    defaults
xz                        5.2.5                h7b6447c_0    defaults
zlib                      1.2.11               h7b6447c_3    defaults
(python36) [root@localhost backup]# 

 退出python36环境,看看外面环境中conda里面的包

[root@localhost backup]# conda list
# packages in environment at /usr/lib64/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0            py36he11e457_0    defaults
alabaster                 0.7.10           py36h306e16b_0    defaults
anaconda                  5.2.0                    py36_3    defaults
anaconda-client           1.6.14                   py36_0    defaults
anaconda-navigator        1.8.7                    py36_0    defaults
anaconda-project          0.8.2            py36h44fb852_0    defaults
asn1crypto                0.24.0                   py36_0    defaults
astroid                   1.6.3                    py36_0    defaults
astropy                   3.0.2            py36h3010b51_1    defaults
attrs                     18.1.0                   py36_0    defaults
babel                     2.5.3                    py36_0    defaults
backcall                  0.1.0                    py36_0    defaults
backports                 1.0              py36hfa02d7e_1    defaults
backports.shutil_get_terminal_size 1.0.0            py36hfea85ff_2    defaults
beautifulsoup4            4.6.0            py36h49b8c8c_1    defaults
bitarray                  0.8.1            py36h14c3975_1    defaults
bkcharts                  0.2              py36h735825a_0    defaults
blas                      1.0                         mkl    defaults
blaze                     0.11.3           py36h4e06776_0    defaults
bleach                    2.1.3                    py36_0    defaults
blosc                     1.14.3               hdbcaa40_0    defaults
bokeh                     0.12.16                  py36_0    defaults
boto                      2.48.0           py36h6e4cd66_1    defaults
bottleneck                1.2.1            py36haac1ea0_0    defaults
bzip2                     1.0.6                h14c3975_5    defaults
ca-certificates           2018.03.07                    0    defaults
cairo                     1.14.12              h7636065_2    defaults
certifi                   2018.4.16                py36_0    defaults
cffi                      1.11.5           py36h9745a5d_0    defaults
chardet                   3.0.4            py36h0f667ec_1    defaults
click                     6.7              py36h5253387_0    defaults
cloudpickle               0.5.3                    py36_0    defaults
clyent                    1.2.2            py36h7e57e65_1    defaults
colorama                  0.3.9            py36h489cec4_0    defaults
conda                     4.5.4                    py36_0    defaults
conda-build               3.10.5                   py36_0    defaults
conda-env                 2.6.0                h36134e3_1    defaults
conda-verify              2.0.0            py36h98955d8_0    defaults
contextlib2               0.5.5            py36h6c84a62_0    defaults
cryptography              2.2.2            py36h14c3975_0    defaults
curl                      7.60.0               h84994c4_0    defaults
cycler                    0.10.0           py36h93f1223_0    defaults
cython                    0.28.2           py36h14c3975_0    defaults
cytoolz                   0.9.0.1          py36h14c3975_0    defaults
dask                      0.17.5                   py36_0    defaults
dask-core                 0.17.5                   py36_0    defaults
datashape                 0.5.4            py36h3ad6b5c_0    defaults
dbus                      1.13.2               h714fa37_1    defaults
decorator                 4.3.0                    py36_0    defaults
distributed               1.21.8                   py36_0    defaults
docutils                  0.14             py36hb0f60f5_0    defaults
entrypoints               0.2.3            py36h1aec115_2    defaults
et_xmlfile                1.0.1            py36hd6bccc3_0    defaults
expat                     2.2.5                he0dffb1_0    defaults
fastcache                 1.0.2            py36h14c3975_2    defaults
filelock                  3.0.4                    py36_0    defaults
flask                     1.0.2                    py36_1    defaults
flask-cors                3.0.4                    py36_0    defaults
fontconfig                2.12.6               h49f89f6_0    defaults
freetype                  2.8                  hab7d2ae_1    defaults
get_terminal_size         1.0.0                haa9412d_0    defaults
gevent                    1.3.0            py36h14c3975_0    defaults
glib                      2.56.1               h000015b_0    defaults
glob2                     0.6              py36he249c77_0    defaults
gmp                       6.1.2                h6c8ec71_1    defaults
gmpy2                     2.0.8            py36hc8893dd_2    defaults
graphite2                 1.3.11               h16798f4_2    defaults
greenlet                  0.4.13           py36h14c3975_0    defaults
gst-plugins-base          1.14.0               hbbd80ab_1    defaults
gstreamer                 1.14.0               hb453b48_1    defaults
h5py                      2.7.1            py36ha1f6525_2    defaults
harfbuzz                  1.7.6                h5f0a787_1    defaults
hdf5                      1.10.2               hba1933b_1    defaults
heapdict                  1.0.0                    py36_2    defaults
html5lib                  1.0.1            py36h2f9c1c0_0    defaults
icu                       58.2                 h9c2bf20_1    defaults
idna                      2.6              py36h82fb2a8_1    defaults
imageio                   2.3.0                    py36_0    defaults
imagesize                 1.0.0                    py36_0    defaults
intel-openmp              2018.0.0                      8    defaults
ipykernel                 4.8.2                    py36_0    defaults
ipython                   6.4.0                    py36_0    defaults
ipython_genutils          0.2.0            py36hb52b0d5_0    defaults
ipywidgets                7.2.1                    py36_0    defaults
isort                     4.3.4                    py36_0    defaults
itsdangerous              0.24             py36h93cc618_1    defaults
jbig                      2.1                  hdba287a_0    defaults
jdcal                     1.4                      py36_0    defaults
jedi                      0.12.0                   py36_1    defaults
jinja2                    2.10             py36ha16c418_0    defaults
jpeg                      9b                   h024ee3a_2    defaults
jsonschema                2.6.0            py36h006f8b5_0    defaults
jupyter                   1.0.0                    py36_4    defaults
jupyter_client            5.2.3                    py36_0    defaults
jupyter_console           5.2.0            py36he59e554_1    defaults
jupyter_core              4.4.0            py36h7c827e3_0    defaults
jupyterlab                0.32.1                   py36_0    defaults
jupyterlab_launcher       0.10.5                   py36_0    defaults
kiwisolver                1.0.1            py36h764f252_0    defaults
lazy-object-proxy         1.3.1            py36h10fcdad_0    defaults
libcurl                   7.60.0               h1ad7b7a_0    defaults
libedit                   3.1.20170329         h6b74fdf_2    defaults
libffi                    3.2.1                hd88cf55_4    defaults
libgcc-ng                 7.2.0                hdf63c60_3    defaults
libgfortran-ng            7.2.0                hdf63c60_3    defaults
libpng                    1.6.34               hb9fc6fc_0    defaults
libsodium                 1.0.16               h1bed415_0    defaults
libssh2                   1.8.0                h9cfc8f7_4    defaults
libstdcxx-ng              7.2.0                hdf63c60_3    defaults
libtiff                   4.0.9                he85c1e1_1    defaults
libtool                   2.4.6                h544aabb_3    defaults
libxcb                    1.13                 h1bed415_1    defaults
libxml2                   2.9.8                h26e45fe_1    defaults
libxslt                   1.1.32               h1312cb7_0    defaults
llvmlite                  0.23.1           py36hdbcaa40_0    defaults
locket                    0.2.0            py36h787c0ad_1    defaults
lxml                      4.2.1            py36h23eabaa_0    defaults
lzo                       2.10                 h49e0be7_2    defaults
markupsafe                1.0              py36hd9260cd_1    defaults
matplotlib                2.2.2            py36h0e671d2_1    defaults
mccabe                    0.6.1            py36h5ad9710_1    defaults
mistune                   0.8.3            py36h14c3975_1    defaults
mkl                       2018.0.2                      1    defaults
mkl-service               1.1.2            py36h17a0993_4    defaults
mkl_fft                   1.0.1            py36h3010b51_0    defaults
mkl_random                1.0.1            py36h629b387_0    defaults
more-itertools            4.1.0                    py36_0    defaults
mpc                       1.0.3                hec55b23_5    defaults
mpfr                      3.1.5                h11a74b3_2    defaults
mpmath                    1.0.0            py36hfeacd6b_2    defaults
msgpack-python            0.5.6            py36h6bb024c_0    defaults
multipledispatch          0.5.0                    py36_0    defaults
navigator-updater         0.2.1                    py36_0    defaults
nbconvert                 5.3.1            py36hb41ffb7_0    defaults
nbformat                  4.4.0            py36h31c9010_0    defaults
ncurses                   6.1                  hf484d3e_0    defaults
networkx                  2.1                      py36_0    defaults
nltk                      3.3.0                    py36_0    defaults
nose                      1.3.7            py36hcdf7029_2    defaults
notebook                  5.5.0                    py36_0    defaults
numba                     0.38.0           py36h637b7d7_0    defaults
numexpr                   2.6.5            py36h7bf3b9c_0    defaults
numpy                     1.14.3           py36hcd700cb_1    defaults
numpy-base                1.14.3           py36h9be14a7_1    defaults
numpydoc                  0.8.0                    py36_0    defaults
odo                       0.5.1            py36h90ed295_0    defaults
olefile                   0.45.1                   py36_0    defaults
openpyxl                  2.5.3                    py36_0    defaults
openssl                   1.0.2o               h20670df_0    defaults
packaging                 17.1                     py36_0    defaults
pandas                    0.23.0           py36h637b7d7_0    defaults
pandoc                    1.19.2.1             hea2e7c5_1    defaults
pandocfilters             1.4.2            py36ha6701b7_1    defaults
pango                     1.41.0               hd475d92_0    defaults
parso                     0.2.0                    py36_0    defaults
partd                     0.3.8            py36h36fd896_0    defaults
patchelf                  0.9                  hf79760b_2    defaults
path.py                   11.0.1                   py36_0    defaults
pathlib2                  2.3.2                    py36_0    defaults
patsy                     0.5.0                    py36_0    defaults
pcre                      8.42                 h439df22_0    defaults
pep8                      1.7.1                    py36_0    defaults
pexpect                   4.5.0                    py36_0    defaults
pickleshare               0.7.4            py36h63277f8_0    defaults
pillow                    5.1.0            py36h3deb7b8_0    defaults
pip                       10.0.1                   py36_0    defaults
pixman                    0.34.0               hceecf20_3    defaults
pkginfo                   1.4.2                    py36_1    defaults
pluggy                    0.6.0            py36hb689045_0    defaults
ply                       3.11                     py36_0    defaults
prompt_toolkit            1.0.15           py36h17d85b1_0    defaults
psutil                    5.4.5            py36h14c3975_0    defaults
ptyprocess                0.5.2            py36h69acd42_0    defaults
py                        1.5.3                    py36_0    defaults
pycodestyle               2.4.0                    py36_0    defaults
pycosat                   0.6.3            py36h0a5515d_0    defaults
pycparser                 2.18             py36hf9f622e_1    defaults
pycrypto                  2.6.1            py36h14c3975_8    defaults
pycurl                    7.43.0.1         py36hb7f436b_0    defaults
pyflakes                  1.6.0            py36h7bd6a15_0    defaults
pygments                  2.2.0            py36h0d3125c_0    defaults
pylint                    1.8.4                    py36_0    defaults
pyodbc                    4.0.23           py36hf484d3e_0    defaults
pyopenssl                 18.0.0                   py36_0    defaults
pyparsing                 2.2.0            py36hee85983_1    defaults
pyqt                      5.9.2            py36h751905a_0    defaults
pysocks                   1.6.8                    py36_0    defaults
pytables                  3.4.3            py36h02b9ad4_2    defaults
pytest                    3.5.1                    py36_0    defaults
pytest-arraydiff          0.2                      py36_0    defaults
pytest-astropy            0.3.0                    py36_0    defaults
pytest-doctestplus        0.1.3                    py36_0    defaults
pytest-openfiles          0.3.0                    py36_0    defaults
pytest-remotedata         0.2.1                    py36_0    defaults
python                    3.6.5                hc3d631a_2    defaults
python-dateutil           2.7.3                    py36_0    defaults
pytz                      2018.4                   py36_0    defaults
pywavelets                0.5.2            py36he602eb0_0    defaults
pyyaml                    3.12             py36hafb9ca4_1    defaults
pyzmq                     17.0.0           py36h14c3975_0    defaults
qt                        5.9.5                h7e424d6_0    defaults
qtawesome                 0.4.4            py36h609ed8c_0    defaults
qtconsole                 4.3.1            py36h8f73b5b_0    defaults
qtpy                      1.4.1                    py36_0    defaults
readline                  7.0                  ha6073c6_4    defaults
requests                  2.18.4           py36he2e5f8d_1    defaults
rope                      0.10.7           py36h147e2ec_0    defaults
ruamel_yaml               0.15.35          py36h14c3975_1    defaults
scikit-image              0.13.1           py36h14c3975_1    defaults
scikit-learn              0.19.1           py36h7aa7ec6_0    defaults
scipy                     1.1.0            py36hfc37229_0    defaults
seaborn                   0.8.1            py36hfad7ec4_0    defaults
send2trash                1.5.0                    py36_0    defaults
setuptools                39.1.0                   py36_0    defaults
simplegeneric             0.8.1                    py36_2    defaults
singledispatch            3.4.0.3          py36h7a266c3_0    defaults
sip                       4.19.8           py36hf484d3e_0    defaults
six                       1.11.0           py36h372c433_1    defaults
snappy                    1.1.7                hbae5bb6_3    defaults
snowballstemmer           1.2.1            py36h6febd40_0    defaults
sortedcollections         0.6.1                    py36_0    defaults
sortedcontainers          1.5.10                   py36_0    defaults
sphinx                    1.7.4                    py36_0    defaults
sphinxcontrib             1.0              py36h6d0f590_1    defaults
sphinxcontrib-websupport  1.0.1            py36hb5cb234_1    defaults
spyder                    3.2.8                    py36_0    defaults
sqlalchemy                1.2.7            py36h6b74fdf_0    defaults
sqlite                    3.23.1               he433501_0    defaults
statsmodels               0.9.0            py36h3010b51_0    defaults
sympy                     1.1.1            py36hc6d1c1c_0    defaults
tblib                     1.3.2            py36h34cf8b6_0    defaults
terminado                 0.8.1                    py36_1    defaults
testpath                  0.3.1            py36h8cadb63_0    defaults
tk                        8.6.7                hc745277_3    defaults
toolz                     0.9.0                    py36_0    defaults
tornado                   5.0.2                    py36_0    defaults
traitlets                 4.3.2            py36h674d592_0    defaults
typing                    3.6.4                    py36_0    defaults
unicodecsv                0.14.1           py36ha668878_0    defaults
unixodbc                  2.3.6                h1bed415_0    defaults
urllib3                   1.22             py36hbe7ace6_0    defaults
wcwidth                   0.1.7            py36hdf4376a_0    defaults
webencodings              0.5.1            py36h800622e_1    defaults
werkzeug                  0.14.1                   py36_0    defaults
wheel                     0.31.1                   py36_0    defaults
widgetsnbextension        3.2.1                    py36_0    defaults
wrapt                     1.10.11          py36h28b7045_0    defaults
xlrd                      1.1.0            py36h1db9f0c_1    defaults
xlsxwriter                1.0.4                    py36_0    defaults
xlwt                      1.3.0            py36h7b00a1f_0    defaults
xz                        5.2.4                h14c3975_4    defaults
yaml                      0.1.7                had09818_2    defaults
zeromq                    4.2.5                h439df22_0    defaults
zict                      0.1.3            py36h3a3bf81_0    defaults
zlib                      1.2.11               ha838bed_2    defaults
[root@localhost backup]# 

可以看到比python36环境下的包多了好多。

6. 删除指定的环境

 
命令:conda env remove --name myenv 
执行这个命令会删除指定的环境


7. 在conda下查看指定环境的包

如果处于conda下而非某个指定的环境下,普通的conda list会列所有的包,此时如果想要查看某个指定的环境下的包,可以使用下面的命令
conda list -n xxxxx
例如要查看python36这个环境下的包

[root@localhost ~]# conda  list -n  python36
# packages in environment at /usr/lib64/anaconda3/envs/python36:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main    defaults
ca-certificates           2021.9.30            h06a4308_1    defaults
certifi                   2021.5.30        py36h06a4308_0    defaults
ld_impl_linux-64          2.35.1               h7274673_9    defaults
libffi                    3.3                  he6710b0_2    defaults
libgcc-ng                 9.1.0                hdf63c60_0    defaults
libstdcxx-ng              9.1.0                hdf63c60_0    defaults
ncurses                   6.2                  he6710b0_1    defaults
openssl                   1.1.1l               h7f8727e_0    defaults
pip                       21.2.2           py36h06a4308_0    defaults
python                    3.6.13               h12debd9_1    defaults
readline                  8.1                  h27cfd23_0    defaults
setuptools                58.0.4           py36h06a4308_0    defaults
sqlite                    3.36.0               hc218d9a_0    defaults
tk                        8.6.11               h1ccaba5_0    defaults
wheel                     0.37.0             pyhd3eb1b0_1    defaults
xz                        5.2.5                h7b6447c_0    defaults
zlib                      1.2.11               h7b6447c_3    defaults
[root@localhost ~]# 

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以在命令行中输入 "conda info" 命令来查看 Anaconda 的安装信息,包括默认安装路径等信息。具体步骤如下: 1. 打开命令行窗口(在 Windows 中,可以按下 Win+R 键,然后输入 "cmd",按下回车键打开命令行窗口); 2. 输入 "conda info" 命令并按下回车键; 3. 等待一段时间,直到命令行输出 Anaconda 的安装信息; 4. 在输出信息中查找 "base environment" 或 "root environment",它们对应的路径就是 Anaconda 的安装路径。 例如,Windows 系统下的输出信息可能如下所示: ``` active environment : None user config file : C:\Users\Username\.condarc populated config files : C:\Users\Username\.condarc conda version : 4.10.3 conda-build version : not installed python version : 3.9.5.final.0 virtual packages : __cuda=11.3=0 __win=0=0 __archspec=1=x86_64 base environment : C:\ProgramData\Anaconda3 (writable) conda av data dir : C:\ProgramData\Anaconda3\etc\conda conda av metadata url : https://repo.anaconda.com/pkgs/main channel URLs : https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:\ProgramData\Anaconda3\pkgs C:\Users\Username\AppData\Local\conda\conda\pkgs envs directories : C:\ProgramData\Anaconda3\envs C:\Users\Username\AppData\Local\conda\conda\envs C:\Users\Username\.conda\envs platform : win-64 user-agent : conda/4.10.3 requests/2.25.1 UID:GID : 0:0 netrc file : None offline mode : False ``` 在这个例子中,Anaconda 的安装路径为 "C:\ProgramData\Anaconda3"。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值