zoukankan      html  css  js  c++  java
  • Anaconda 科学计算环境与包的管理

    相信大多数 python 的初学者们都曾为开发环境问题折腾了很久,包管理和 python 不同版本的问题,特别是 window 环境安装个 scrapy 各种报错 ,使用 Anaconda 可以很好的解决一些不必要的学习成本。

    Anaconda 概述

    Anaconda 是一个用于科学计算的 python发行版,支持 Linux, Mac, Windows系统,提供了包管理与虚拟环境管理的功能,可以很方便地解决多版本 python 并存、切换以及各种第三方包安装问题。可以使用 conda 来进行 package 和 environment 的管理,并且已经包含了 python科学包及其依赖项和相关的配套工具。Anaconda 提供两个不同版本的版本,分别对应 python2.7 和 python 3.x,根据自身的选择就好,后续也可以使用 conda 自由切换 python 的运行环境。

    package list
    https://docs.continuum.io/anaconda/pkg-docs

    conda 包管理

    conda 是 Anaconda 下用于包管理(packages)和环境管理(environment)工具,功能上类似 pip 和 virtualenv,pyenv等工具管理虚拟环境的组合。

    • 包管理工具:可以使用 conda 来安装、更新 、卸载工具包 ,并且它更关注于数据科学相关的工具包。在安装 Anaconda 时就预先集成了像 numpy、scipy、 pandas、scikit-learn 这些在数据分析中常用的包。另外值得一提的是,conda 并不仅仅管理 python 的工具包,它也能安装非 python 的包。比如在新版的 Anaconda 中就可以安装R语言的集成开发环境 Rstudio。
    • 虚拟环境管理:在conda中可以建立多个虚拟环境,用于隔离不同项目所需的不同版本的工具包,以防止版本上的冲突。对纠结于 python 版本的同学们,我们也可以建立 python2 和 python3 两个环境,来分别运行不同版本的 python 代码。

    使用 conda 切换 python 运行环境 (对环境变量PATH的替换)

    # 创建一个名为 python3 的环境,指定 python 版本是3.6
    conda create --name python3 python=3.6
    # 创建一个名为 python2 的版本为 python2.7 的环境。
    conda create -n python2 python=2.7
    # 激活环境
    activate python3 # for Windows
    source activate python3 # for Linux & Mac
    # 验证是否生效
    python --version
    # 返回默认的环境
    deactivate python3 # for Windows
    source deactivate python3 # for Linux & Mac
    # 删除一个已有的环境
    conda remove --name python3 --all

    conda 常用命令

    # 查看已经安装的packages
    conda list
    # 升级所有包
    conda upgrade --all
    # 查找package信息
    conda search scrapy
    # 安装包  (如果不用-n指定环境名称,则被安装在当前活跃环境)
    conda install -n python3 scrapy scikit-learn
    # 更新package
    conda update -n python3 scrapy
    # 删除package
    conda remove -n python3 scrapy
    # 更新conda
    conda update conda
    # 更新anaconda
    conda update anaconda
    # 更新python(将python升级当前最新版本)
    conda update python
    # 添加tsinghua镜像(conda的配置路径 ~/.condarc(Linux/Mac)或C:UsersUSER_NAME.condarc文件)
    conda config --add channels
    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    # 设置搜索地址
    conda config --set show_channel_urls yes
    # 查询设置结果
    conda config --get channels

    #安装的包

    #Anaconda(https://www.continuum.io/downloads#linux)
    wget https://repo.continuum.io/archive/Anaconda3-4.3.1-Linux-x86_64.sh
    sudo bash Anaconda3-4.3.1-Linux-x86_64.sh
    Anaconda3 will now be installed into this location:
    /root/anaconda3

    - Press ENTER to confirm the location
    - Press CTRL-C to abort the installation
    - Or specify a different location below

    [/root/anaconda3] >>> ENTER
    PREFIX=/opt/ENTER
    installing: python-3.6.0-0 ...
    installing: _license-1.1-py36_1 ...
    installing: alabaster-0.7.9-py36_0 ...
    installing: anaconda-client-1.6.0-py36_0 ...
    installing: anaconda-navigator-1.5.0-py36_0 ...
    installing: anaconda-project-0.4.1-py36_0 ...
    installing: astroid-1.4.9-py36_0 ...
    installing: astropy-1.3-np111py36_0 ...
    installing: babel-2.3.4-py36_0 ...
    installing: backports-1.0-py36_0 ...
    installing: beautifulsoup4-4.5.3-py36_0 ...
    installing: bitarray-0.8.1-py36_0 ...
    installing: blaze-0.10.1-py36_0 ...
    installing: bokeh-0.12.4-py36_0 ...
    installing: boto-2.45.0-py36_0 ...
    installing: bottleneck-1.2.0-np111py36_0 ...
    installing: cairo-1.14.8-0 ...
    installing: cffi-1.9.1-py36_0 ...
    installing: chardet-2.3.0-py36_0 ...
    installing: chest-0.2.3-py36_0 ...
    installing: click-6.7-py36_0 ...
    installing: cloudpickle-0.2.2-py36_0 ...
    installing: clyent-1.2.2-py36_0 ...
    installing: colorama-0.3.7-py36_0 ...
    installing: configobj-5.0.6-py36_0 ...
    installing: contextlib2-0.5.4-py36_0 ...
    installing: cryptography-1.7.1-py36_0 ...
    installing: curl-7.52.1-0 ...
    installing: cycler-0.10.0-py36_0 ...
    installing: cython-0.25.2-py36_0 ...
    installing: cytoolz-0.8.2-py36_0 ...
    installing: dask-0.13.0-py36_0 ...
    installing: datashape-0.5.4-py36_0 ...
    installing: dbus-1.10.10-0 ...
    installing: decorator-4.0.11-py36_0 ...
    installing: dill-0.2.5-py36_0 ...
    installing: docutils-0.13.1-py36_0 ...
    installing: entrypoints-0.2.2-py36_0 ...
    installing: et_xmlfile-1.0.1-py36_0 ...
    installing: expat-2.1.0-0 ...
    installing: fastcache-1.0.2-py36_1 ...
    installing: flask-0.12-py36_0 ...
    installing: flask-cors-3.0.2-py36_0 ...
    installing: fontconfig-2.12.1-2 ...
    installing: freetype-2.5.5-2 ...
    installing: get_terminal_size-1.0.0-py36_0 ...
    installing: gevent-1.2.1-py36_0 ...
    installing: glib-2.50.2-1 ...
    installing: greenlet-0.4.11-py36_0 ...
    installing: gst-plugins-base-1.8.0-0 ...
    installing: gstreamer-1.8.0-0 ...
    installing: h5py-2.6.0-np111py36_2 ...
    installing: harfbuzz-0.9.39-2 ...
    installing: hdf5-1.8.17-1 ...
    installing: heapdict-1.0.0-py36_1 ...
    installing: icu-54.1-0 ...
    installing: idna-2.2-py36_0 ...
    installing: imagesize-0.7.1-py36_0 ...
    installing: ipykernel-4.5.2-py36_0 ...
    installing: ipython-5.1.0-py36_0 ...
    installing: ipython_genutils-0.1.0-py36_0 ...
    installing: ipywidgets-5.2.2-py36_1 ...
    installing: isort-4.2.5-py36_0 ...
    installing: itsdangerous-0.24-py36_0 ...
    installing: jbig-2.1-0 ...
    installing: jdcal-1.3-py36_0 ...
    installing: jedi-0.9.0-py36_1 ...
    installing: jinja2-2.9.4-py36_0 ...
    installing: jpeg-9b-0 ...
    installing: jsonschema-2.5.1-py36_0 ...
    installing: jupyter-1.0.0-py36_3 ...
    installing: jupyter_client-4.4.0-py36_0 ...
    installing: jupyter_console-5.0.0-py36_0 ...
    installing: jupyter_core-4.2.1-py36_0 ...
    installing: lazy-object-proxy-1.2.2-py36_0 ...
    installing: libffi-3.2.1-1 ...
    installing: libgcc-4.8.5-2 ...
    installing: libgfortran-3.0.0-1 ...
    installing: libiconv-1.14-0 ...
    installing: libpng-1.6.27-0 ...
    installing: libsodium-1.0.10-0 ...
    installing: libtiff-4.0.6-3 ...
    installing: libxcb-1.12-1 ...
    installing: libxml2-2.9.4-0 ...
    installing: libxslt-1.1.29-0 ...
    installing: llvmlite-0.15.0-py36_0 ...
    installing: locket-0.2.0-py36_1 ...
    installing: lxml-3.7.2-py36_0 ...
    installing: markupsafe-0.23-py36_2 ...
    installing: matplotlib-2.0.0-np111py36_0 ...
    installing: mistune-0.7.3-py36_0 ...
    installing: mkl-2017.0.1-0 ...
    installing: mkl-service-1.1.2-py36_3 ...
    installing: mpmath-0.19-py36_1 ...
    installing: multipledispatch-0.4.9-py36_0 ...
    installing: nbconvert-4.2.0-py36_0 ...
    installing: nbformat-4.2.0-py36_0 ...
    installing: networkx-1.11-py36_0 ...
    installing: nltk-3.2.2-py36_0 ...
    installing: nose-1.3.7-py36_1 ...
    installing: notebook-4.3.1-py36_0 ...
    installing: numba-0.30.1-np111py36_0 ...
    installing: numexpr-2.6.1-np111py36_2 ...
    installing: numpy-1.11.3-py36_0 ...
    installing: numpydoc-0.6.0-py36_0 ...
    installing: odo-0.5.0-py36_1 ...
    installing: openpyxl-2.4.1-py36_0 ...
    installing: openssl-1.0.2k-1 ...
    installing: pandas-0.19.2-np111py36_1 ...
    installing: partd-0.3.7-py36_0 ...
    installing: path.py-10.0-py36_0 ...
    installing: pathlib2-2.2.0-py36_0 ...
    installing: patsy-0.4.1-py36_0 ...
    installing: pcre-8.39-1 ...
    installing: pep8-1.7.0-py36_0 ...
    installing: pexpect-4.2.1-py36_0 ...
    installing: pickleshare-0.7.4-py36_0 ...
    installing: pillow-4.0.0-py36_0 ...
    installing: pip-9.0.1-py36_1 ...
    installing: pixman-0.34.0-0 ...
    installing: ply-3.9-py36_0 ...
    installing: prompt_toolkit-1.0.9-py36_0 ...
    installing: psutil-5.0.1-py36_0 ...
    installing: ptyprocess-0.5.1-py36_0 ...
    installing: py-1.4.32-py36_0 ...
    installing: pyasn1-0.1.9-py36_0 ...
    installing: pycosat-0.6.1-py36_1 ...
    installing: pycparser-2.17-py36_0 ...
    installing: pycrypto-2.6.1-py36_4 ...
    installing: pycurl-7.43.0-py36_2 ...
    installing: pyflakes-1.5.0-py36_0 ...
    installing: pygments-2.1.3-py36_0 ...
    installing: pylint-1.6.4-py36_1 ...
    installing: pyopenssl-16.2.0-py36_0 ...
    installing: pyparsing-2.1.4-py36_0 ...
    installing: pyqt-5.6.0-py36_2 ...
    installing: pytables-3.3.0-np111py36_0 ...
    installing: pytest-3.0.5-py36_0 ...
    installing: python-dateutil-2.6.0-py36_0 ...
    installing: pytz-2016.10-py36_0 ...
    installing: pyyaml-3.12-py36_0 ...
    installing: pyzmq-16.0.2-py36_0 ...
    installing: qt-5.6.2-3 ...
    installing: qtawesome-0.4.3-py36_0 ...
    installing: qtconsole-4.2.1-py36_1 ...
    installing: qtpy-1.2.1-py36_0 ...
    installing: readline-6.2-2 ...
    installing: redis-3.2.0-0 ...
    installing: redis-py-2.10.5-py36_0 ...
    installing: requests-2.12.4-py36_0 ...
    installing: rope-0.9.4-py36_1 ...
    installing: ruamel_yaml-0.11.14-py36_1 ...
    installing: scikit-image-0.12.3-np111py36_1 ...
    installing: scikit-learn-0.18.1-np111py36_1 ...
    installing: scipy-0.18.1-np111py36_1 ...
    installing: seaborn-0.7.1-py36_0 ...
    installing: setuptools-27.2.0-py36_0 ...
    installing: simplegeneric-0.8.1-py36_1 ...
    installing: singledispatch-3.4.0.3-py36_0 ...
    installing: sip-4.18-py36_0 ...
    installing: six-1.10.0-py36_0 ...
    installing: snowballstemmer-1.2.1-py36_0 ...
    installing: sockjs-tornado-1.0.3-py36_0 ...
    installing: sphinx-1.5.1-py36_0 ...
    installing: spyder-3.1.2-py36_0 ...
    installing: sqlalchemy-1.1.5-py36_0 ...
    installing: sqlite-3.13.0-0 ...
    installing: statsmodels-0.6.1-np111py36_1 ...
    installing: sympy-1.0-py36_0 ...
    installing: terminado-0.6-py36_0 ...
    installing: tk-8.5.18-0 ...
    installing: toolz-0.8.2-py36_0 ...
    installing: tornado-4.4.2-py36_0 ...
    installing: traitlets-4.3.1-py36_0 ...
    installing: unicodecsv-0.14.1-py36_0 ...
    installing: wcwidth-0.1.7-py36_0 ...
    installing: werkzeug-0.11.15-py36_0 ...
    installing: wheel-0.29.0-py36_0 ...
    installing: widgetsnbextension-1.2.6-py36_0 ...
    installing: wrapt-1.10.8-py36_0 ...
    installing: xlrd-1.0.0-py36_0 ...
    installing: xlsxwriter-0.9.6-py36_0 ...
    installing: xlwt-1.2.0-py36_0 ...
    installing: xz-5.2.2-1 ...
    installing: yaml-0.1.6-0 ...
    installing: zeromq-4.1.5-0 ...
    installing: zlib-1.2.8-3 ...
    installing: anaconda-4.3.1-np111py36_0 ...
    installing: conda-4.3.14-py36_0 ...
    installing: conda-env-2.6.0-0 ...
    Python 3.6.0 :: Continuum Analytics, Inc.
    creating default environment...
    installation finished.
    Do you wish the installer to prepend the Anaconda3 install location
    to PATH in your /root/.bashrc ? [yes|no]
    [no] >>> yes

    Prepending PATH=/opt/ENTER/bin to PATH in /root/.bashrc
    A backup will be made to: /root/.bashrc-anaconda3.bak


    For this change to become active, you have to open a new terminal.

    Thank you for installing Anaconda3!

    Share your notebooks and packages on Anaconda Cloud!
    Sign up for free: https://anaconda.org

     # Peter Wang于2015年10月21日在纽约召开的Strata + Hadoop世界2015年会上接受O'reilly出版集团的访谈(练习英语)

    http://mp.weixin.qq.com/s?__biz=MzAwNDc0MTUxMw==&mid=2649639177&idx=1&sn=2bf4ee8815a7cef0a760771c910c7af8

    REFER:
    http://conda.pydata.org/docs/_downloads/conda-cheatsheet.pdf
    https://www.continuum.io/downloads
    https://docs.continuum.io/anaconda
    https://conda.io/docs

  • 相关阅读:
    WSGI学习系列WSME
    Murano Weekly Meeting 2015.08.11
    Trace Logging Level
    OpenStack Weekly Rank 2015.08.10
    markdown语法测试集合
    css-定位
    html图像、绝对路径和相对路径,链接
    html块、含样式的标签
    html标题、段落、换行与字符实体
    html概述和基本结构
  • 原文地址:https://www.cnblogs.com/Irving/p/6651730.html
Copyright © 2011-2022 走看看