配置spark的jupyter notebook kernel -- spark magic

1、下载livy https://livy.incubator.apache.org/
解压,进入livy文件夹,然后运行bin/livy-server

2、安装sparkmagic

pip install sparkmagic
jupyter nbextension enable --py --sys-prefix widgetsnbextension 

下边是可选部分:
pip show sparkmagic,会出现类似如下结果:

Name: sparkmagic
Version: 0.12.5
Summary: SparkMagic: Spark execution via Livy
Home-page: https://github.com/jupyter-incubator/sparkmagic
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.org
License: BSD 3-clause
Location: /Users/xiligey/anaconda3/lib/python3.6/site-packages
Requires: tornado, notebook, autovizwidget, hdijupyterutils, nose, ipykernel, ipywidgets, pandas, requests-kerberos, numpy, mock, ipython, requests
Required-by:

进入到上边的location,运行

 jupyter-kernelspec install sparkmagic/kernels/sparkkernel
 jupyter-kernelspec install sparkmagic/kernels/pysparkkernel
 jupyter-kernelspec install sparkmagic/kernels/pyspark3kernel
 jupyter-kernelspec install sparkmagic/kernels/sparkrkernel

3、启动jupyter notebook
jupyter notebook
然后新建一个Spark

13641823-bf55244e3f32dda0.png
新建一个Spark Notebook

4、遇到的问题
在新建一个spark notebook之后报错:

The code failed because of a fatal error:
    Failed to register auto viz for notebook.
Exception details:
    "cannot import name 'DataError'".

Some things to try:
a) Make sure Spark has enough available resources for Jupyter to create a Spark context.
b) Contact your Jupyter administrator to make sure the Spark magics library is configured correctly.
c) Restart the kernel.

原因是目前而言,sparkmagic最新版和python pandas最新版本不兼容

可以回退一下pandas版本来解决报错:
pip install pandas==0.22.0

最终的界面:


13641823-824da38269b0938b.png
image.png

然后就可以开心的用spark交互界面码代码了:)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值