在 jupyter 中用 scala 编写 Spark 程序

0 前提条件

  • JDK
  • Spark
  • Scala
  • Python
  • jupyter 包

1 安装 spylon-kernel

pip install spylon-kernel

常见问题:

ERROR: Could not find a version that satisfies the requirement findspark (from spylon[spark]->spylon-kernel) (from versions: none)
ERROR: No matching distribution found for findspark (from spylon[spark]->spylon-kernel)

解决办法:使用国内源

pip install spylon_kernel -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

2 创建 spylon-kernel

python -m spylon_kernel install

3 配置 SPARK_HOME 环境变量

vim ~/.bash_profile
i # 插入
export SPARK_HOME=/Users/your_user_name/spark-3.0.1-bin-hadoop2.7

# 注意:这里的路径填写你自己SPARK的安装路径

4 运行 jupyter

jupyter notebook

打开:localhost:8888

5 使用

  1. 点击“新建”按钮,选择 spylon-kernel
    在这里插入图片描述
  2. 在代码块中输入任意一段合法代码,运行即可。
  3. 用 sc 或 spark 开始初始化一个 RDD 或 DataFrame 。
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值