我正在研究 Kafka 流媒体并尝试将其与 Apache Spark 集成。但是,在运行时我遇到了问题。我收到以下错误。
这是我正在使用的命令。
df_TR = Spark.readStream.format("kafka").option("kafka.bootstrap.servers", "localhost:9092").option("subscribe", "taxirides").load()
错误:
Py4JJavaError:调用o77.load时出错。:java.lang.ClassNotFoundException:找不到数据源:kafka。请在http://spark.apache.org/third-party-projects.html找到软件包
我该如何解决这个问题?
注意:我在 Jupyter Notebook 中运行它
findspark.init('/home/karan/spark-2.1.0-bin-hadoop2.7')
import pyspark
from pyspark.sql import SparkSession
Spark = SparkSession.builder.appName('KafkaStreaming').getOrCreate()
from pyspark.sql.types import *
from pyspark.streaming import StreamingContext
from pyspark.streaming.kafka import KafkaUtils
Run Code Online (Sandbox Code Playgroud)
一切都运行良好,直到这里(上面的代码)
df_TR = Spark.readStream.format("kafka").option("kafka.bootstrap.servers", "localhost:9092").option("subscribe", "taxirides").load()
这就是出错的地方(上面的代码)。
我正在关注的博客:https : //www.adaltas.com/en/2019/04/18/spark-streaming-data-pipelines-with-structured-streaming/