Apache Zeppelin 的 Jupyter 解释器
概述
项目 Jupyter 旨在开发开源软件、开放标准和服务,以支持跨多种编程语言的交互式计算。 Zeppelin 的 Jupyter 解释器是 Zeppelin 解释器和 Jupyter 内核之间的桥梁/适配器。只要安装了必要的依赖项,您就可以使用任何 Jupyter 内核。
配置
要在Zeppelin中运行任何Jupyter内核,首先需要安装以下先决条件:
- pip 安装 jupyter-client
- pip 安装 grpcio
- pip 安装 protobuf
然后你需要安装你想使用的jupyter内核。在接下来的部分中,我们将讨论如何在Zeppelin中使用以下3种jupyter内核:
- ipython
- ir
- 朱莉娅
Jupyter Python 内核
为了在Zeppelin中使用Jupyter Python内核,你需要先安装ipykernel。
pip install ipykernel
然后你可以在Jupyter解释器中运行如下所示的Python代码。
%jupyter(kernel=python)
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot([1, 2, 3])

Jupyter R 内核
为了使用IRKernel,你需要首先在R中安装IRkernel包。
install.packages('IRkernel')
IRkernel::installspec() # to register the kernel in the current R installation
然后你可以在Jupyter解释器中运行R代码,如下所示。
%jupyter(kernel=ir)
library(ggplot2)
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point()

Jupyter Julia 内核
为了在Zeppelin中使用Julia,首先需要安装IJulia
using Pkg
Pkg.add("IJulia")
然后你可以在Jupyter解释器中运行julia代码,如下所示。
%jupyter(kernel=julia-1.3)
using Pkg
Pkg.add("Plots")
using Plots
plotly() # Choose the Plotly.jl backend for web interactivity
plot(rand(5,5),linewidth=2,title="My Plot")
Pkg.add("PyPlot") # Install a different backend
pyplot() # Switch to using the PyPlot.jl backend
plot(rand(5,5),linewidth=2,title="My Plot")

使用任何其他内核
对于任何其他的jupyter内核,您可以按照以下步骤在Zeppelin中使用它。
- 安装指定的jupyter内核。你可以在这里找到所有可用的jupyter内核 here
- 通过运行以下命令找到其内核名称
bash jupyter kernelspec list - 按照以下方式运行内核
%jupyter(kernel=kernel_name)
code