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 使用
- 点击“新建”按钮,选择 spylon-kernel
- 在代码块中输入任意一段合法代码,运行即可。
- 用 sc 或 spark 开始初始化一个 RDD 或 DataFrame 。