https://www.jianshu.com/p/2f3be7781451
http://blog.csdn.net/u012318074/article/details/77075209
https://zhuanlan.zhihu.com/p/24664358
http://blog.csdn.net/Yushl_sirius/article/details/77866411
https://www.jianshu.com/p/62f155eb6ac5
https://blog.csdn.net/qq_29719097/article/details/78762278
0、序
Python易用,但用好却不易,其中比较头疼的就是包管理和Python不同版本的问题,特别是当你使用Windows的时候。为了解决这些问题,有不少发行版的Python,比如WinPython、Anaconda等,这些发行版将python和许多常用的package打包,方便pythoners直接使用,此外,还有virtualenv、pyenv等工具管理虚拟环境。
个人尝试了很多类似的发行版,最终选择了Anaconda,因为其强大而方便的包管理与环境管理的功能。该文主要介绍下Anaconda,对Anaconda的理解,并简要总结下相关的操作。
1、Anaconda概述
1.1、简介
Anaconda是一个用于科学计算的Python发行版,支持 Linux,Mac, Windows系统,提供了包管理与环境管理的功能,可以很方便地解决多版本python并存、切换以及各种第三方包安装问题。Anaconda利用工具/命令conda来进行package和environment的管理,并且已经包含了Python和相关的配套工具。
这里先解释下conda、anaconda这些概念的差别。conda可以理解为一个工具,也是一个可执行命令,其核心功能是包管理与环境管理。包管理与pip的使用类似,环境管理则允许用户方便地安装不同版本的python并可以快速切换。Anaconda则是一个打包的集合,里面预装好了conda、某个版本的python、众多packages、科学计算工具等等,所以也称为Python的一种发行版。其实还有Miniconda,顾名思义,它只包含最基本的内容——python与conda,以及相关的必须依赖项,对于空间要求严格的用户,Miniconda是一种选择。
进入下文之前,说明一下conda的设计理念——conda将几乎所有的工具、第三方包都当做package对待,甚至包括python和conda自身!因此,conda打破了包管理与环境管理的约束,能非常方便地安装各种版本python、各种package并方便地切换。
1.2、特点
Anaconda具有如下特点:
(1)开源
(2)安装过程简单
(3)高性能使用Python和R语言
(4)免费的社区支持
其特点的实现主要基于Anaconda拥有的:
(1)conda包
(2)环境管理器
(3)1,000+开源库
如果日常工作或学习并不必要使用1,000多个库,那么可以考虑安装Miniconda(图形界面下载及命令行安装请戳),这里不过多介绍Miniconda的安装及使用。
1.3、Anaconda、conda、pip、virtualenv的区别
① Anaconda
Anaconda是一个包含180+的科学包及其依赖项的发行版本。其包含的科学包包括:conda, numpy, scipy, ipython notebook等。
② conda
(1)conda是包及其依赖项和环境的管理工具。
(2)适用语言:Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, FORTRAN。
(3)适用平台:Windows, macOS, Linux
(4)用途:
1、快速安装、运行和升级包及其依赖项。
2、在计算机中便捷地创建、保存、加载和切换环境。
如果你需要的包要求不同版本的Python,你无需切换到不同的环境,因为conda同样是一个环境管理器。仅需要几条命令,你可以创建一个完全独立的环境来运行不同的Python版本,同时继续在你常规的环境中使用你常用的Python版本。——conda官方网站
(6)conda包和环境管理器包含于Anaconda的所有版本当中。
(1)pip是用于安装和管理软件包的包管理器。
(2)pip编写语言:Python。
(3)Python中默认安装的版本:
Python 2.7.9及后续版本:默认安装,命令为pip
Python 3.4及后续版本:默认安装,命令为pip3
(4)pip名称的由来:pip采用的是递归缩写进行命名的。其名字被普遍认为来源于2处:
“Pip installs Packages”(“pip安装包”)
“Pip installs Python”(“pip安装Python”)
(1)virtualenv:用于创建一个独立的Python环境的工具。
(2)解决问题:
1、当一个程序需要使用Python 2.7版本,而另一个程序需要使用Python 3.6版本,如何同时使用这两个程序?
2、如果将所有程序都安装在系统下的默认路径,如:/usr/lib/python2.7/site-packages,当不小心升级了本不该升级的程序时,将会对其他的程序造成影响。
3、如果想要安装程序并在程序运行时对其库或库的版本进行修改,都会导致程序的中断。
4、在共享主机时,无法在全局site-packages目录中安装包。
(3)virtualenv将会为它自己的安装目录创建一个环境,这并不与其他virtualenv环境共享库;同时也可以选择性地不连接已安装的全局库。
→ 依赖项检查
pip:
(1)不一定会展示所需其他依赖包。
(2)安装包时或许会直接忽略依赖项而安装,仅在结果中提示错误。
conda:
(1)列出所需其他依赖包。
(2)安装包时自动安装其依赖项。
(3)可以便捷地在包的不同版本中自由切换。
→ 环境管理pip:维护多个环境难度较大。
conda:比较方便地在不同环境之间进行切换,环境管理较为简单。
→ 对系统自带Python的影响pip:在系统自带Python中包的**更新/回退版本/卸载将影响其他程序。
conda:不会影响系统自带Python。
→ 适用语言pip:仅适用于Python。
conda:适用于Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, FORTRAN。
⑥ conda与pip、virtualenv的关系
conda结合了pip和virtualenv的功能。
2、Anaconda的安装
Anaconda的下载页参见官网下载 https://www.anaconda.com/download/,Linux、Mac、Windows均支持。
安装时,会发现有两个不同版本的Anaconda,分别对应Python 2.7和Python 3.5,两个版本其实除了这点区别外其他都一样。后面我们会看到,安装哪个版本并不本质,因为通过环境管理,我们可以很方便地切换运行时的Python版本。
2.1、linux下安装anaconda
要使用Python 3.6版本,需要使用Anaconda3-5.0.1-Linux-x86_64.sh版本,因为它默认使用的是Python 3.6,在官网地址上进行下载。
下载完之后,在终端输入:bash Anaconda3-5.0.1-Linux-x86_64.sh
整个过程点几下回车就好了。但是到最后一步,会提示是否把anaconda加入到系统环境变量中:
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] >>>
PREFIX=/root/anaconda3
installing: python-3.6.3-hc9025b9_1 ...
Python 3.6.3 :: Anaconda, Inc.
installing: ca-certificates-2017.08.26-h1d4fec5_0 ...
installing: conda-env-2.6.0-h36134e3_1 ...
installing: intel-openmp-2018.0.0-h15fc484_7 ...
installing: libgcc-ng-7.2.0-h7cc24e2_2 ...
installing: libgfortran-ng-7.2.0-h9f7466a_2 ...
installing: libstdcxx-ng-7.2.0-h7a57d05_2 ...
installing: bzip2-1.0.6-h0376d23_1 ...
installing: expat-2.2.4-hc00ebd1_1 ...
installing: gmp-6.1.2-hb3b607b_0 ...
installing: graphite2-1.3.10-hc526e54_0 ...
installing: icu-58.2-h211956c_0 ...
installing: jbig-2.1-hdba287a_0 ...
installing: jpeg-9b-habf39ab_1 ...
installing: libffi-3.2.1-h4deb6c0_3 ...
installing: libsodium-1.0.13-h31c71d8_2 ...
installing: libssh2-1.8.0-h8c220ad_2 ...
installing: libtool-2.4.6-hd50d1a6_0 ...
installing: libxcb-1.12-h84ff03f_3 ...
installing: lzo-2.10-h1bfc0ba_1 ...
installing: mkl-2018.0.0-hb491cac_4 ...
installing: ncurses-6.0-h06874d7_1 ...
installing: openssl-1.0.2l-h077ae2c_5 ...
installing: patchelf-0.9-hf79760b_2 ...
installing: pcre-8.41-hc71a17e_0 ...
installing: pixman-0.34.0-h83dc358_2 ...
installing: tk-8.6.7-h5979e9b_1 ...
installing: unixodbc-2.3.4-hc36303a_1 ...
installing: xz-5.2.3-h2bcbf08_1 ...
installing: yaml-0.1.7-h96e3832_1 ...
installing: zlib-1.2.11-hfbfcf68_1 ...
installing: curl-7.55.1-hcb0b314_2 ...
installing: glib-2.53.6-hc861d11_1 ...
installing: hdf5-1.10.1-hb0523eb_0 ...
installing: libedit-3.1-heed3624_0 ...
installing: libpng-1.6.32-hda9c8bc_2 ...
installing: libtiff-4.0.8-h90200ff_9 ...
installing: libxml2-2.9.4-h6b072ca_5 ...
installing: mpfr-3.1.5-h12ff648_1 ...
installing: pandoc-1.19.2.1-hea2e7c5_1 ...
installing: readline-7.0-hac23ff0_3 ...
installing: zeromq-4.2.2-hb0b69da_1 ...
installing: dbus-1.10.22-h3b5a359_0 ...
installing: freetype-2.8-h52ed37b_0 ...
installing: gstreamer-1.12.2-h4f93127_0 ...
installing: libxslt-1.1.29-hcf9102b_5 ...
installing: mpc-1.0.3-hf803216_4 ...
installing: sqlite-3.20.1-h6d8b0f3_1 ...
installing: fontconfig-2.12.4-h88586e7_1 ...
installing: gst-plugins-base-1.12.2-he3457e5_0 ...
installing: alabaster-0.7.10-py36h306e16b_0 ...
installing: asn1crypto-0.22.0-py36h265ca7c_1 ...
installing: backports-1.0-py36hfa02d7e_1 ...
installing: beautifulsoup4-4.6.0-py36h49b8c8c_1 ...
installing: bitarray-0.8.1-py36h5834eb8_0 ...
installing: boto-2.48.0-py36h6e4cd66_1 ...
installing: cairo-1.14.10-haa5651f_5 ...
installing: certifi-2017.7.27.1-py36h8b7b77e_0 ...
installing: chardet-3.0.4-py36h0f667ec_1 ...
installing: click-6.7-py36h5253387_0 ...
installing: cloudpickle-0.4.0-py36h30f8c20_0 ...
installing: colorama-0.3.9-py36h489cec4_0 ...
installing: contextlib2-0.5.5-py36h6c84a62_0 ...
installing: dask-core-0.15.3-py36h10e6167_0 ...
installing: decorator-4.1.2-py36hd076ac8_0 ...
installing: docutils-0.14-py36hb0f60f5_0 ...
installing: entrypoints-0.2.3-py36h1aec115_2 ...
installing: et_xmlfile-1.0.1-py36hd6bccc3_0 ...
installing: fastcache-1.0.2-py36h5b0c431_0 ...
installing: filelock-2.0.12-py36hacfa1f5_0 ...
installing: glob2-0.5-py36h2c1b292_1 ...
installing: gmpy2-2.0.8-py36h55090d7_1 ...
installing: greenlet-0.4.12-py36h2d503a6_0 ...
installing: heapdict-1.0.0-py36h79797d7_0 ...
installing: idna-2.6-py36h82fb2a8_1 ...
installing: imagesize-0.7.1-py36h52d8127_0 ...
installing: ipython_genutils-0.2.0-py36hb52b0d5_0 ...
installing: itsdangerous-0.24-py36h93cc618_1 ...
installing: jdcal-1.3-py36h4c697fb_0 ...
installing: jedi-0.10.2-py36h552def0_0 ...
installing: lazy-object-proxy-1.3.1-py36h10fcdad_0 ...
installing: llvmlite-0.20.0-py36_0 ...
installing: locket-0.2.0-py36h787c0ad_1 ...
installing: lxml-4.1.0-py36h5b66e50_0 ...
installing: markupsafe-1.0-py36hd9260cd_1 ...
installing: mccabe-0.6.1-py36h5ad9710_1 ...
installing: mistune-0.7.4-py36hbab8784_0 ...
installing: mkl-service-1.1.2-py36h17a0993_4 ...
installing: mpmath-0.19-py36h8cc018b_2 ...
installing: msgpack-python-0.4.8-py36hec4c5d1_0 ...
installing: multipledispatch-0.4.9-py36h41da3fb_0 ...
installing: numpy-1.13.3-py36ha12f23b_0 ...
installing: olefile-0.44-py36h79f9f78_0 ...
installing: pandocfilters-1.4.2-py36ha6701b7_1 ...
installing: path.py-10.3.1-py36he0c6f6d_0 ...
installing: pep8-1.7.0-py36h26ade29_0 ...
installing: pickleshare-0.7.4-py36h63277f8_0 ...
installing: pkginfo-1.4.1-py36h215d178_1 ...
installing: ply-3.10-py36hed35086_0 ...
installing: psutil-5.4.0-py36h84c53db_0 ...
installing: ptyprocess-0.5.2-py36h69acd42_0 ...
installing: py-1.4.34-py36h0712aa3_1 ...
installing: pycodestyle-2.3.1-py36hf609f19_0 ...
installing: pycosat-0.6.2-py36h1a0ea17_1 ...
installing: pycparser-2.18-py36hf9f622e_1 ...
installing: pycrypto-2.6.1-py36h6998063_1 ...
installing: pycurl-7.43.0-py36h5e72054_3 ...
installing: pyodbc-4.0.17-py36h999153c_0 ...
installing: pyparsing-2.2.0-py36hee85983_1 ...
installing: pysocks-1.6.7-py36hd97a5b1_1 ...
installing: pytz-2017.2-py36hc2ccc2a_1 ...
installing: pyyaml-3.12-py36hafb9ca4_1 ...
installing: pyzmq-16.0.2-py36h3b0cf96_2 ...
installing: qt-5.6.2-h974d657_12 ...
installing: qtpy-1.3.1-py36h3691cc8_0 ...
installing: rope-0.10.5-py36h1f8c17e_0 ...
installing: ruamel_yaml-0.11.14-py36ha2fb22d_2 ...
installing: simplegeneric-0.8.1-py36h2cb9092_0 ...
installing: sip-4.18.1-py36h51ed4ed_2 ...
installing: six-1.11.0-py36h372c433_1 ...
installing: snowballstemmer-1.2.1-py36h6febd40_0 ...
installing: sortedcontainers-1.5.7-py36hdf89491_0 ...
installing: sphinxcontrib-1.0-py36h6d0f590_1 ...
installing: sqlalchemy-1.1.13-py36hfb5efd7_0 ...
installing: tblib-1.3.2-py36h34cf8b6_0 ...
installing: testpath-0.3.1-py36h8cadb63_0 ...
installing: toolz-0.8.2-py36h81f2dff_0 ...
installing: tornado-4.5.2-py36h1283b2a_0 ...
installing: typing-3.6.2-py36h7da032a_0 ...
installing: unicodecsv-0.14.1-py36ha668878_0 ...
installing: wcwidth-0.1.7-py36hdf4376a_0 ...
installing: webencodings-0.5.1-py36h800622e_1 ...
installing: werkzeug-0.12.2-py36hc703753_0 ...
installing: wrapt-1.10.11-py36h28b7045_0 ...
installing: xlrd-1.1.0-py36h1db9f0c_1 ...
installing: xlsxwriter-1.0.2-py36h3de1aca_0 ...
installing: xlwt-1.3.0-py36h7b00a1f_0 ...
installing: babel-2.5.0-py36h7d14adf_0 ...
installing: backports.shutil_get_terminal_size-1.0.0-py36hfea85ff_2 ...
installing: bottleneck-1.2.1-py36haac1ea0_0 ...
installing: cffi-1.10.0-py36had8d393_1 ...
installing: conda-verify-2.0.0-py36h98955d8_0 ...
installing: cycler-0.10.0-py36h93f1223_0 ...
installing: cytoolz-0.8.2-py36h708bfd4_0 ...
installing: h5py-2.7.0-py36he81ebca_1 ...
installing: harfbuzz-1.5.0-h2545bd6_0 ...
installing: html5lib-0.999999999-py36h2cfc398_0 ...
installing: networkx-2.0-py36h7e96fb8_0 ...
installing: nltk-3.2.4-py36h1a0979f_0 ...
installing: numba-0.35.0-np113py36_10 ...
installing: numexpr-2.6.2-py36hdd3393f_1 ...
installing: openpyxl-2.4.8-py36h41dd2a8_1 ...
installing: packaging-16.8-py36ha668100_1 ...
installing: partd-0.3.8-py36h36fd896_0 ...
installing: pathlib2-2.3.0-py36h49efa8e_0 ...
installing: pexpect-4.2.1-py36h3b9d41b_0 ...
installing: pillow-4.2.1-py36h9119f52_0 ...
installing: pyqt-5.6.0-py36h0386399_5 ...
installing: python-dateutil-2.6.1-py36h88d3b88_1 ...
installing: pywavelets-0.5.2-py36he602eb0_0 ...
installing: qtawesome-0.4.4-py36h609ed8c_0 ...
installing: scipy-0.19.1-py36h9976243_3 ...
installing: setuptools-36.5.0-py36he42e2e1_0 ...
installing: singledispatch-3.4.0.3-py36h7a266c3_0 ...
installing: sortedcollections-0.5.3-py36h3c761f9_0 ...
installing: sphinxcontrib-websupport-1.0.1-py36hb5cb234_1 ...
installing: sympy-1.1.1-py36hc6d1c1c_0 ...
installing: terminado-0.6-py36ha25a19f_0 ...
installing: traitlets-4.3.2-py36h674d592_0 ...
installing: zict-0.1.3-py36h3a3bf81_0 ...
installing: astroid-1.5.3-py36hbdb9df2_0 ...
installing: bleach-2.0.0-py36h688b259_0 ...
installing: clyent-1.2.2-py36h7e57e65_1 ...
installing: cryptography-2.0.3-py36ha225213_1 ...
installing: cython-0.26.1-py36h21c49d0_0 ...
installing: datashape-0.5.4-py36h3ad6b5c_0 ...
installing: distributed-1.19.1-py36h25f3894_0 ...
installing: get_terminal_size-1.0.0-haa9412d_0 ...
installing: gevent-1.2.2-py36h2fe25dc_0 ...
installing: imageio-2.2.0-py36he555465_0 ...
installing: isort-4.2.15-py36had401c0_0 ...
installing: jinja2-2.9.6-py36h489bce4_1 ...
installing: jsonschema-2.6.0-py36h006f8b5_0 ...
installing: jupyter_core-4.3.0-py36h357a921_0 ...
installing: matplotlib-2.1.0-py36hba5de38_0 ...
installing: navigator-updater-0.1.0-py36h14770f7_0 ...
installing: nose-1.3.7-py36hcdf7029_2 ...
installing: pandas-0.20.3-py36h842e28d_2 ...
installing: pango-1.40.11-h8191d47_0 ...
installing: patsy-0.4.1-py36ha3be15e_0 ...
installing: pyflakes-1.6.0-py36h7bd6a15_0 ...
installing: pygments-2.2.0-py36h0d3125c_0 ...
installing: pytables-3.4.2-py36h3b5282a_2 ...
installing: pytest-3.2.1-py36h11ad3bb_1 ...
installing: scikit-learn-0.19.1-py36h7aa7ec6_0 ...
installing: wheel-0.29.0-py36he7f4e38_1 ...
installing: astropy-2.0.2-py36ha51211e_4 ...
installing: bkcharts-0.2-py36h735825a_0 ...
installing: bokeh-0.12.10-py36hbb0e44a_0 ...
installing: flask-0.12.2-py36hb24657c_0 ...
installing: jupyter_client-5.1.0-py36h614e9ea_0 ...
installing: nbformat-4.4.0-py36h31c9010_0 ...
installing: pip-9.0.1-py36h8ec8b28_3 ...
installing: prompt_toolkit-1.0.15-py36h17d85b1_0 ...
installing: pylint-1.7.4-py36hb9d4533_0 ...
installing: pyopenssl-17.2.0-py36h5cc804b_0 ...
installing: statsmodels-0.8.0-py36h8533d0b_0 ...
installing: dask-0.15.3-py36hdc2c8aa_0 ...
installing: flask-cors-3.0.3-py36h2d857d3_0 ...
installing: ipython-6.1.0-py36hc72a948_1 ...
installing: nbconvert-5.3.1-py36hb41ffb7_0 ...
installing: seaborn-0.8.0-py36h197244f_0 ...
installing: urllib3-1.22-py36hbe7ace6_0 ...
installing: ipykernel-4.6.1-py36hbf841aa_0 ...
installing: odo-0.5.1-py36h90ed295_0 ...
installing: requests-2.18.4-py36he2e5f8d_1 ...
installing: scikit-image-0.13.0-py36had3c07a_1 ...
installing: anaconda-client-1.6.5-py36h19c0dcd_0 ...
installing: blaze-0.11.3-py36h4e06776_0 ...
installing: conda-4.3.30-py36h5d9f9f4_0 ...
installing: jupyter_console-5.2.0-py36he59e554_1 ...
installing: notebook-5.0.0-py36h0b20546_2 ...
installing: qtconsole-4.3.1-py36h8f73b5b_0 ...
installing: sphinx-1.6.3-py36he5f0bdb_0 ...
installing: anaconda-project-0.8.0-py36h29abdf5_0 ...
installing: conda-build-3.0.27-py36h940a66d_0 ...
installing: jupyterlab_launcher-0.4.0-py36h4d8058d_0 ...
installing: numpydoc-0.7.0-py36h18f165f_0 ...
installing: widgetsnbextension-3.0.2-py36hd01bb71_1 ...
installing: anaconda-navigator-1.6.9-py36h11ddaaa_0 ...
installing: ipywidgets-7.0.0-py36h7b55c3a_0 ...
installing: jupyterlab-0.27.0-py36h86377d0_2 ...
installing: spyder-3.2.4-py36hbe6152b_0 ...
installing: _ipyw_jlab_nb_ext_conf-0.1.0-py36he11e457_0 ...
installing: jupyter-1.0.0-py36h9896ce5_0 ...
installing: anaconda-5.0.1-py36hd30a520_1 ...
installation finished.
Do you wish the installer to prepend the Anaconda3 install location
to PATH in your /root/.bashrc ? [yes|no]
建议像我这样的菜鸟来说,就不要加了,直接回车,默认就是no。
如果在安装Anaconda的过程中没有将安装路径添加到系统环境变量中,需要在安装后手工添加:
方法一:
1、在终端输入 vim /etc/profile,打开profile文件。
2、在文件末尾添加一行:export PATH=/root/anaconda3/bin:$PATH,其中,将“/root/anaconda3/bin”替换为你实际的安装路径。保存。
3、让/etc/profile文件修改后立即生效 ,可以使用如下命令: source /etc/profile方法二:
对于Mac、Linux系统,Anaconda安装好后,实际上就是在主目录下多了个文件夹(~/anaconda)而已,Windows会写入注册表。安装时,安装程序会把bin目录加入PATH(Linux/Mac写入~/.bashrc,Windows添加到系统变量PATH),这些操作也完全可以自己完成。以Linux/Mac为例,安装完成后设置PATH的操作是:
# 将anaconda的bin目录加入PATH,根据版本不同,也可能是~/anaconda3/bin
echo 'export PATH="~/anaconda2/bin:$PATH"' >> ~/.bashrc
# 更新bashrc以立即生效
source ~/.bashrc
验证安装结果,可选用以下任意一种方法:
1、在终端输入命令:conda,会出现conda命令说明:
2、在终端中输入命令condal list
,如果Anaconda被成功安装,则会显示已经安装的包名和版本号。
输入命令:conda list,可以查看Anaconda管理的所有包:
[root@localhost ~]# conda list
# packages in environment at /root/anaconda3:
#
_ipyw_jlab_nb_ext_conf 0.1.0 py36he11e457_0
alabaster 0.7.10 py36h306e16b_0
anaconda 5.0.1 py36hd30a520_1
anaconda-client 1.6.5 py36h19c0dcd_0
anaconda-navigator 1.6.9 py36h11ddaaa_0
anaconda-project 0.8.0 py36h29abdf5_0
asn1crypto 0.22.0 py36h265ca7c_1
astroid 1.5.3 py36hbdb9df2_0
astropy 2.0.2 py36ha51211e_4
babel 2.5.0 py36h7d14adf_0
backports 1.0 py36hfa02d7e_1
backports.shutil_get_terminal_size 1.0.0 py36hfea85ff_2
beautifulsoup4 4.6.0 py36h49b8c8c_1
bitarray 0.8.1 py36h5834eb8_0
bkcharts 0.2 py36h735825a_0
blaze 0.11.3 py36h4e06776_0
bleach 2.0.0 py36h688b259_0
bokeh 0.12.10 py36hbb0e44a_0
boto 2.48.0 py36h6e4cd66_1
bottleneck 1.2.1 py36haac1ea0_0
bzip2 1.0.6 h0376d23_1
ca-certificates 2017.08.26 h1d4fec5_0
cairo 1.14.10 haa5651f_5
certifi 2017.7.27.1 py36h8b7b77e_0
cffi 1.10.0 py36had8d393_1
chardet 3.0.4 py36h0f667ec_1
click 6.7 py36h5253387_0
cloudpickle 0.4.0 py36h30f8c20_0
clyent 1.2.2 py36h7e57e65_1
colorama 0.3.9 py36h489cec4_0
conda 4.3.30 py36h5d9f9f4_0
conda-build 3.0.27 py36h940a66d_0
conda-env 2.6.0 h36134e3_1
conda-verify 2.0.0 py36h98955d8_0
contextlib2 0.5.5 py36h6c84a62_0
cryptography 2.0.3 py36ha225213_1
curl 7.55.1 hcb0b314_2
cycler 0.10.0 py36h93f1223_0
cython 0.26.1 py36h21c49d0_0
cytoolz 0.8.2 py36h708bfd4_0
dask 0.15.3 py36hdc2c8aa_0
dask-core 0.15.3 py36h10e6167_0
datashape 0.5.4 py36h3ad6b5c_0
dbus 1.10.22 h3b5a359_0
decorator 4.1.2 py36hd076ac8_0
distributed 1.19.1 py36h25f3894_0
docutils 0.14 py36hb0f60f5_0
entrypoints 0.2.3 py36h1aec115_2
et_xmlfile 1.0.1 py36hd6bccc3_0
expat 2.2.4 hc00ebd1_1
fastcache 1.0.2 py36h5b0c431_0
filelock 2.0.12 py36hacfa1f5_0
flask 0.12.2 py36hb24657c_0
flask-cors 3.0.3 py36h2d857d3_0
fontconfig 2.12.4 h88586e7_1
freetype 2.8 h52ed37b_0
get_terminal_size 1.0.0 haa9412d_0
gevent 1.2.2 py36h2fe25dc_0
glib 2.53.6 hc861d11_1
glob2 0.5 py36h2c1b292_1
gmp 6.1.2 hb3b607b_0
gmpy2 2.0.8 py36h55090d7_1
graphite2 1.3.10 hc526e54_0
greenlet 0.4.12 py36h2d503a6_0
gst-plugins-base 1.12.2 he3457e5_0
gstreamer 1.12.2 h4f93127_0
h5py 2.7.0 py36he81ebca_1
harfbuzz 1.5.0 h2545bd6_0
hdf5 1.10.1 hb0523eb_0
heapdict 1.0.0 py36h79797d7_0
html5lib 0.999999999 py36h2cfc398_0
icu 58.2 h211956c_0
idna 2.6 py36h82fb2a8_1
imageio 2.2.0 py36he555465_0
imagesize 0.7.1 py36h52d8127_0
intel-openmp 2018.0.0 h15fc484_7
ipykernel 4.6.1 py36hbf841aa_0
ipython 6.1.0 py36hc72a948_1
ipython_genutils 0.2.0 py36hb52b0d5_0
ipywidgets 7.0.0 py36h7b55c3a_0
isort 4.2.15 py36had401c0_0
itsdangerous 0.24 py36h93cc618_1
jbig 2.1 hdba287a_0
jdcal 1.3 py36h4c697fb_0
jedi 0.10.2 py36h552def0_0
jinja2 2.9.6 py36h489bce4_1
jpeg 9b habf39ab_1
jsonschema 2.6.0 py36h006f8b5_0
jupyter 1.0.0 py36h9896ce5_0
jupyter_client 5.1.0 py36h614e9ea_0
jupyter_console 5.2.0 py36he59e554_1
jupyter_core 4.3.0 py36h357a921_0
jupyterlab 0.27.0 py36h86377d0_2
jupyterlab_launcher 0.4.0 py36h4d8058d_0
lazy-object-proxy 1.3.1 py36h10fcdad_0
libedit 3.1 heed3624_0
libffi 3.2.1 h4deb6c0_3
libgcc-ng 7.2.0 h7cc24e2_2
libgfortran-ng 7.2.0 h9f7466a_2
libpng 1.6.32 hda9c8bc_2
libsodium 1.0.13 h31c71d8_2
libssh2 1.8.0 h8c220ad_2
libstdcxx-ng 7.2.0 h7a57d05_2
libtiff 4.0.8 h90200ff_9
libtool 2.4.6 hd50d1a6_0
libxcb 1.12 h84ff03f_3
libxml2 2.9.4 h6b072ca_5
libxslt 1.1.29 hcf9102b_5
llvmlite 0.20.0 py36_0
locket 0.2.0 py36h787c0ad_1
lxml 4.1.0 py36h5b66e50_0
lzo 2.10 h1bfc0ba_1
markupsafe 1.0 py36hd9260cd_1
matplotlib 2.1.0 py36hba5de38_0
mccabe 0.6.1 py36h5ad9710_1
mistune 0.7.4 py36hbab8784_0
mkl 2018.0.0 hb491cac_4
mkl-service 1.1.2 py36h17a0993_4
mpc 1.0.3 hf803216_4
mpfr 3.1.5 h12ff648_1
mpmath 0.19 py36h8cc018b_2
msgpack-python 0.4.8 py36hec4c5d1_0
multipledispatch 0.4.9 py36h41da3fb_0
navigator-updater 0.1.0 py36h14770f7_0
nbconvert 5.3.1 py36hb41ffb7_0
nbformat 4.4.0 py36h31c9010_0
ncurses 6.0 h06874d7_1
networkx 2.0 py36h7e96fb8_0
nltk 3.2.4 py36h1a0979f_0
nose 1.3.7 py36hcdf7029_2
notebook 5.0.0 py36h0b20546_2
numba 0.35.0 np113py36_10
numexpr 2.6.2 py36hdd3393f_1
numpy 1.13.3 py36ha12f23b_0
numpydoc 0.7.0 py36h18f165f_0
odo 0.5.1 py36h90ed295_0
olefile 0.44 py36h79f9f78_0
openpyxl 2.4.8 py36h41dd2a8_1
openssl 1.0.2l h077ae2c_5
packaging 16.8 py36ha668100_1
pandas 0.20.3 py36h842e28d_2
pandoc 1.19.2.1 hea2e7c5_1
pandocfilters 1.4.2 py36ha6701b7_1
pango 1.40.11 h8191d47_0
partd 0.3.8 py36h36fd896_0
patchelf 0.9 hf79760b_2
path.py 10.3.1 py36he0c6f6d_0
pathlib2 2.3.0 py36h49efa8e_0
patsy 0.4.1 py36ha3be15e_0
pcre 8.41 hc71a17e_0
pep8 1.7.0 py36h26ade29_0
pexpect 4.2.1 py36h3b9d41b_0
pickleshare 0.7.4 py36h63277f8_0
pillow 4.2.1 py36h9119f52_0
pip 9.0.1 py36h8ec8b28_3
pixman 0.34.0 h83dc358_2
pkginfo 1.4.1 py36h215d178_1
ply 3.10 py36hed35086_0
prompt_toolkit 1.0.15 py36h17d85b1_0
psutil 5.4.0 py36h84c53db_0
ptyprocess 0.5.2 py36h69acd42_0
py 1.4.34 py36h0712aa3_1
pycodestyle 2.3.1 py36hf609f19_0
pycosat 0.6.2 py36h1a0ea17_1
pycparser 2.18 py36hf9f622e_1
pycrypto 2.6.1 py36h6998063_1
pycurl 7.43.0 py36h5e72054_3
pyflakes 1.6.0 py36h7bd6a15_0
pygments 2.2.0 py36h0d3125c_0
pylint 1.7.4 py36hb9d4533_0
pyodbc 4.0.17 py36h999153c_0
pyopenssl 17.2.0 py36h5cc804b_0
pyparsing 2.2.0 py36hee85983_1
pyqt 5.6.0 py36h0386399_5
pysocks 1.6.7 py36hd97a5b1_1
pytables 3.4.2 py36h3b5282a_2
pytest 3.2.1 py36h11ad3bb_1
python 3.6.3 hc9025b9_1
python-dateutil 2.6.1 py36h88d3b88_1
pytz 2017.2 py36hc2ccc2a_1
pywavelets 0.5.2 py36he602eb0_0
pyyaml 3.12 py36hafb9ca4_1
pyzmq 16.0.2 py36h3b0cf96_2
qt 5.6.2 h974d657_12
qtawesome 0.4.4 py36h609ed8c_0
qtconsole 4.3.1 py36h8f73b5b_0
qtpy 1.3.1 py36h3691cc8_0
readline 7.0 hac23ff0_3
requests 2.18.4 py36he2e5f8d_1
rope 0.10.5 py36h1f8c17e_0
ruamel_yaml 0.11.14 py36ha2fb22d_2
scikit-image 0.13.0 py36had3c07a_1
scikit-learn 0.19.1 py36h7aa7ec6_0
scipy 0.19.1 py36h9976243_3
seaborn 0.8.0 py36h197244f_0
setuptools 36.5.0 py36he42e2e1_0
simplegeneric 0.8.1 py36h2cb9092_0
singledispatch 3.4.0.3 py36h7a266c3_0
sip 4.18.1 py36h51ed4ed_2
six 1.11.0 py36h372c433_1
snowballstemmer 1.2.1 py36h6febd40_0
sortedcollections 0.5.3 py36h3c761f9_0
sortedcontainers 1.5.7 py36hdf89491_0
sphinx 1.6.3 py36he5f0bdb_0
sphinxcontrib 1.0 py36h6d0f590_1
sphinxcontrib-websupport 1.0.1 py36hb5cb234_1
spyder 3.2.4 py36hbe6152b_0
sqlalchemy 1.1.13 py36hfb5efd7_0
sqlite 3.20.1 h6d8b0f3_1
statsmodels 0.8.0 py36h8533d0b_0
sympy 1.1.1 py36hc6d1c1c_0
tblib 1.3.2 py36h34cf8b6_0
terminado 0.6 py36ha25a19f_0
testpath 0.3.1 py36h8cadb63_0
tk 8.6.7 h5979e9b_1
toolz 0.8.2 py36h81f2dff_0
tornado 4.5.2 py36h1283b2a_0
traitlets 4.3.2 py36h674d592_0
typing 3.6.2 py36h7da032a_0
unicodecsv 0.14.1 py36ha668878_0
unixodbc 2.3.4 hc36303a_1
urllib3 1.22 py36hbe7ace6_0
wcwidth 0.1.7 py36hdf4376a_0
webencodings 0.5.1 py36h800622e_1
werkzeug 0.12.2 py36hc703753_0
wheel 0.29.0 py36he7f4e38_1
widgetsnbextension 3.0.2 py36hd01bb71_1
wrapt 1.10.11 py36h28b7045_0
xlrd 1.1.0 py36h1db9f0c_1
xlsxwriter 1.0.2 py36h3de1aca_0
xlwt 1.3.0 py36h7b00a1f_0
xz 5.2.3 h2bcbf08_1
yaml 0.1.7 h96e3832_1
zeromq 4.2.2 hb0b69da_1
zict 0.1.3 py36h3a3bf81_0
zlib 1.2.11 hfbfcf68_1
3、在终端中输入python
。这条命令将会启动Python交互界面,如果Anaconda被成功安装并且可以运行,则将会在Python版本号的右边显示“Anaconda custom (64-bit)”。退出Python交互界面则输入exit()
或quit()
即可。
2.2、windows下安装anaconda
(1)我使用的是 Python 3.6 版本,这里使用Anaconda3-5.0.1-Windows-x86_64版本,因为它默认使用的是 Python 3.6,官方下载地址:https://repo.continuum.io/archive/。
安装时勾选添加环境变量,注册为默认python。若未添加环境变量或不是默认python,请百度更改。
1、windows安装Anaconda的安装路径中一定不要有空格,同时不能是“unicode”编码,否则之后出现莫名其妙的安装编译错误。
2、路径和文件名最好以英文命名,不要以中文或其他特殊字符命名。
3、尽量按照Anaconda默认的行为安装——不使用root权限,仅为个人安装,安装目录设置在个人主目录下(Windows就无所谓了)。这样的好处是,同一台机器上的不同用户完全可以安装、配置自己的Anaconda,不会互相影响。
4、在“Advanced Installation Options”中不要勾选“Add Anaconda to my PATH environment variable.”(“添加Anaconda至我的环境变量。”)。因为如果勾选,则将会影响其他程序的使用。如果使用Anaconda,则通过打开Anaconda Navigator或者在开始菜单中的“Anaconda Prompt”(类似macOS中的“终端”)中进行使用。
除非你打算使用多个版本的Anaconda或者多个版本的Python,否则便勾选“Register Anaconda as my default Python 3.6”。
验证安装结果,可选以下任意方法:
1、“开始 → Anaconda3(64-bit)→ Anaconda Navigator”,若可以成功启动Anaconda Navigator则说明安装成功。
2、“开始 → Anaconda3(64-bit)→ 右键点击Anaconda Prompt → 以管理员身份运行”,在Anaconda Prompt中输入conda list,可以查看已经安装的包名和版本号。若结果可以正常显示,则说明安装成功。
配置环境变量,在cmd命令内可以使用anaconda安装的python包。
在path中添加F:\Anaconda3\Scripts;F:\Anaconda3;
这样在cmd中可以找到anaconda安装的包。
配置pycharm环境,将 Anconda 的解释器添加进 Pycharm中。
(1)双击运行 Pycharm,如下图所示,选择“文件”,“设置”
(2)在框选处搜索“解释器”,选择相应的设置项,并且在右侧的框选处,选择 Anaconda 安装路径下的 python.exe 文件,选择“确定”。
(3)尝试 import numpy,import 成功即表示成功。
3、Anaconda的使用
# 添加Anaconda的TUNA镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
2、启动Python IDE Spyder:
在命令窗口直接输入spyder,系统会自动启动spyder3。
3、常用的conda命令:
1)查看当前环境下已安装的包:conda list
2)查看版本号:conda --version
3)查找package信息:conda search XXXX (XXXX为你要查找的包名称
4)安装package :conda install -n XXXX(环境名称) XXXX(要安装的package名称)
# 如果不用-n指定环境名称,则被安装在当前活跃环境
# 也可以通过-c指定通过某个channel安装
5)更新package :conda update -n XXXX(环境名称) XXXX(要更新的package名称)
6)删除package :conda remove -n XXXX(环境名称) XXXX(要更新的package名称)
7)查看conda配置
(1)conda info 或者 conda info --env
4、创建多python环境,将conda的环境变量写入~/bashrc
常用命令
conda create --name project_env python=3.6
conda info -envs
source activate project_env
deactivate
conda install -n project_env numpy
conda update -n project_env numpy
需要默认环境
conda install -n project_env anaconda
conda create -n project_env python=3.6 anaconda
conda list -n project_env
删除已有环境
conda remove --name project_env --all
其他命令
conda config --show
conda 移除镜像源
conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
实践
➜ ~ conda info -e
# conda environments:
#
res_test /Users/lishulong/anaconda3/envs/res_test
root * /Users/lishulong/anaconda3
➜ ~ conda remove --name res_rest --all
CondaEnvironmentNotFoundError: Could not find environment: res_rest .
You can list all discoverable environments with `conda info --envs`.
➜ ~ source activate res_test
(res_test) ➜ ~ python -V
Python 3.6.2 :: Continuum Analytics, Inc.
(res_test) ➜ ~ deactivate
Error: deactivate must be sourced. Run 'source deactivate'
instead of 'deactivate'.
(res_test) ➜ ~ source deactivate
➜ ~ conda remove --name res_test --all
Package plan for package removal in environment /Users/lishulong/anaconda3/envs/res_test:
The following packages will be REMOVED:
certifi: 2016.2.28-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
openssl: 1.0.2l-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pip: 9.0.1-py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
python: 3.6.2-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
readline: 6.2-2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
setuptools: 36.4.0-py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
sqlite: 3.13.0-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tk: 8.5.18-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
wheel: 0.29.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
xz: 5.2.3-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
zlib: 1.2.11-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
Proceed ([y]/n)? y
➜ ~ conda info -e
# conda environments:
#
root * /Users/lishulong/anaconda3
➜ ~
可见 激活后才可以remove
另外,清华Anaconda镜像地址:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/