Anaconda 科學計算環境與包的管理

相信大多數 python 的初學者們都曾爲開發環境問題折騰了好久,包管理和 python 不一樣版本的問題,特別是 window 環境安裝個 scrapy 各類報錯 ,使用 Anaconda 能夠很好的解決一些沒必要要的學習成本。python

Anaconda 概述

Anaconda 是一個用於科學計算的 python發行版,支 持 Linux, Mac, Windows系統,提供了包管理與虛擬環境管理的功能,能夠很方便地解決多版本 python 並存、切換以及各類第三方包安裝問題。可使用 conda 來進行 package 和 environment 的管理,而且已經包含了 python科學包及其依賴項和相關的配套工具。Anaconda 提供兩個不一樣版本的版本,分別對應 python2.7 和 python 3.x,根據自身的選擇就好,後續也可使用 conda 自由切換 python 的運行環境。linux

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

 

conda 包管理

conda 是 Anaconda 下用於包管理(packages)和環境管理(environment)工具,功能上相似 pip 和 virtualenv,pyenv等工具管理虛擬環境的組合。sql

  • 包管理工具:可使用 conda 來安裝、更新 、卸載工具包 ,而且它更關注於數據科學相關的工具包。在安裝 Anaconda 時就預先集成了像 numpy、scipy、 pandas、scikit-learn 這些在數據分析中經常使用的包。另外值得一提的是,conda 並不單單管理 python 的工具包,它也能安裝非 python 的包。好比在新版的 Anaconda 中就能夠安裝R語言的集成開發環境 Rstudio。
  • 虛擬環境管理:在conda中能夠創建多個虛擬環境,用於隔離不一樣項目所需的不一樣版本的工具包,以防止版本上的衝突。對糾結於 python 版本的同窗們,咱們也能夠創建 python2 和 python3 兩個環境,來分別運行不一樣版本的 python 代碼。

使用 conda 切換 python 運行環境 (對環境變量PATH的替換)json

# 建立一個名爲 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
flask

conda 經常使用命令bash

# 查看已經安裝的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:\Users\USER_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
babel

#安裝的包cors

#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出版集團的訪談(練習英語)python2.7

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

相關文章
相關標籤/搜索