如何使用 Spark 和 Python 在 HDP 2.2 中更新 python 2.7

How to update python 2.7 in HDP 2.2 using with Spark and Python

我正在尝试在 HDP 2.2 中使用 Ipython 和 Spark,但似乎 ipython 仅受 python 2.7 支持。 我已经安装了 Spark 并且测试良好,但是在使用 yum 命令安装 ipython 之后 python 的版本是一个问题。

[root@sandbox spark12]# ipython
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
Type "copyright", "credits" or "license" for more information.

IPython 0.13.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

Ipython 单独运行,但是当我尝试将它与 pyspark 一起使用时:

[root@sandbox spark12]# IPYTHON=1 ./bin/pyspark
IPython requires Python 2.7+; please install python2.7 or set PYSPARK_PYTHON

我想知道如何将 python 2.6 更新到 2.7。看来系统阻止我卸载 python 2.6。我的感觉是 Python 与hadoop系统集成,很难单独更新。

  1. Python没有和Hadoop系统集成。
  2. Python 2.6.6 是 Centos 6.5 / RHEL 6 的默认版本。
  3. 您在任何情况下都不应尝试 uninstall/update 默认版本,因为它具有系统依赖性。
  4. 您可以做的是 python 的 install a newer 版本作为现有版本的替代。 并使用新版本启动 IPython。

我知道有点晚了,但我在使用 CentOS 时遇到了类似的问题。

通过下载 Python 2.7 版本的 Anaconda 发行版

,我能够相对轻松地解决它

wget http://repo.continuum.io/archive/Anaconda2-2.5.0-Linux-x86_64.sh

下载完成后

bash Anaconda2-2.5.0-Linux-x86_64.sh

然后按照说明 - 选择安装 anaconda 的位置并将此位置添加到您的路径中。

完成后,输入

source ~/.bashrc

然后您应该能够 运行 IPython 使用 Pyspark

[user@quickstart ~]$ IPYTHON_OPTS="notebook" $SPARK_HOME/bin/pyspark [I 09:43:06.241 NotebookApp] Serving notebooks from local directory: /home/user [I 09:43:06.241 NotebookApp] 0 active kernels [I 09:43:06.241 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/