Anaconda简介及CentOS下的安装及使用

转自:https://blog.csdn.net/Yushl_sirius/article/details/77866411python

1、Anaconda简介git

 

    Anaconda是一个用于科学计算的Python发行版,支持 Linux, Mac, Windows系统,提供了包管理与环境管理的功能,能够很方便地解决多版本python并存、切换以及各类第三方包安装问题。Anaconda利用工具/命令conda来进行package和environment的管理,而且已经包含了Python和相关的配套工具。express

    这里先解释下conda、anaconda这些概念的差异。conda能够理解为一个工具,也是一个可执行命令,其核心功能是包管理与环境管理。包管理与pip的使用相似,环境管理则容许用户方便地安装不一样版本的python并能够快速切换。Anaconda则是一个打包的集合,里面预装好了conda、某个版本的python、众多packages、科学计算工具等等,因此也称为Python的一种发行版。其实还有Miniconda,顾名思义,它只包含最基本的内容——python与conda,以及相关的必须依赖项,对于空间要求严格的用户,Miniconda是一种选择。bash

    说明一下conda的设计理念——conda将几乎全部的工具、第三方包都当作package对待,甚至包括python和conda自身。所以,conda打破了包管理与环境管理的约束,能很是方便地安装各类版本python、各类package并方便地切换。服务器

2、CentOS下的Anaconda安装app

一、下载Anaconda,下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/工具

    以Anaconda3-4.4.0-Linux-x86_64为例,在上述站点(或者官网)将Anaconda3-4.4.0-Linux-x86_64.sh文件下载到本地,这里如下载到本地Downloads目录为例。ui

二、安装Anacondathis

    打开Linux命令行窗口(Terminal),进入Anaconda3-4.4.0-Linux-x86_64.sh所在目录,输入命令:bashAnaconda3-4.4.0-Linux-x86_64.sh,而后窗口会出现more,而后一直回车往下翻,会看到一个让你输入yes/no,输入yes回车,窗口会出现各类包install列表;而后会让你回车继续,按回车;而后过一下子又会出现让你输入yes/no,输入yes;安装结束。url

    从新打开Terminal,输入命令:conda,会出现conda命令说明:

[sirius@localhost Downloads]$ conda
usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    info         Display information about current conda install.
    help         Displays a list of available conda commands and their help
                 strings.
    list         List linked packages in a conda environment.
    search       Search for packages and display their information. The input
                 is a Python regular expression. To perform a search with a
                 search string that starts with a -, separate the search from
                 the options with --, like 'conda search -- -h'. A * in the
                 results means that package is installed in the current
                 environment. A . means that package is not installed but is
                 cached in the pkgs directory.
    create       Create a new conda environment from a list of specified
                 packages.
    install      Installs a list of packages into a specified conda
                 environment.
    update       Updates conda packages to the latest compatible version. This
                 command accepts a list of package names and updates them to
                 the latest versions that are compatible with all other
                 packages in the environment. Conda attempts to install the
                 newest versions of the requested packages. To accomplish
                 this, it may update some packages that are already installed,
                 or install additional packages. To prevent existing packages
                 from updating, use the --no-update-deps option. This may
                 force conda to install older versions of the requested
                 packages, and it does not prevent additional dependency
                 packages from being installed. If you wish to skip dependency
                 checking altogether, use the '--force' option. This may
                 result in an environment with incompatible packages, so this
                 option must be used with great caution.
    upgrade      Alias for conda update. See conda update --help.
    remove       Remove a list of packages from a specified conda environment.
    uninstall    Alias for conda remove. See conda remove --help.
    config       Modify configuration values in .condarc. This is modeled
                 after the git config command. Writes to the user .condarc
                 file (/home/sirius/.condarc) by default.
    clean        Remove unused packages and caches.
    package      Low-level conda package utility. (EXPERIMENTAL)

optional arguments:
  -h, --help     Show this help message and exit.
  -V, --version  Show the conda version number and exit.

other commands, such as "conda build", are available when additional conda
packages (e.g. conda-build) are installed

    输入命令:conda list,能够查看Anaconda管理的全部包:

 

 

3、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

 

 

二、启动Python IDE Spyder:

    在命令窗口直接输入spyder,系统会自动启动spyder3。

 

三、经常使用的conda命令:

    1)、 查看当前环境下已安装的包:conda list

    2)、查找package信息:conda search XXXX   (XXXX为你要查找的包名称)

    3)、安装package :conda install -n XXXX(环境名称) XXXX(要安装的package名称)

                   # 若是不用-n指定环境名称,则被安装在当前活跃环境
                   # 也能够经过-c指定经过某个channel安装
 
    4)、更新package :conda update -n XXXX(环境名称) XXXX(要更新的package名称)
 
    5)、删除package :conda remove -n XXXX(环境名称) XXXX(要更新的package名称)
相关文章
相关标签/搜索