Spark结构化流媒体找不到结构化_network_wordcount.py

时间:2018-12-26 23:42:22

标签: apache-spark spark-structured-streaming

我是Spark的新手,正在学习结构化流tutorial。在Python中使用spark 2.4。

我在终端中运行nc -lk 9999。然后在笔记本中,根据教程

在下面运行
from pyspark.sql import SparkSession
from pyspark.sql.functions import explode
from pyspark.sql.functions import split

spark = SparkSession \
    .builder \
    .appName("StructuredNetworkWordCount") \
    .getOrCreate()

# Create DataFrame representing the stream of input lines from connection to localhost:9999
lines = spark \
    .readStream \
    .format("socket") \
    .option("host", "localhost") \
    .option("port", 9999) \
    .load()

# Split the lines into words
words = lines.select(
   explode(
       split(lines.value, " ")
   ).alias("word")
)

# Generate running word count
wordCounts = words.groupBy("word").count()

 # Start running the query that prints the running counts to the console
query = wordCounts \
    .writeStream \
    .outputMode("complete") \
    .format("console") \
    .start()

query.awaitTermination()

现在在另一个终端上,我进入s park-2.4.0-bin-hadoop2.7文件夹并运行

$ ./bin/spark-submit examples/src/main/python/sql/streaming/structured_network_wordcount.py localhost 9999

哪个给我错误

Error executing Jupyter command '/Users/myusername/spark-2.4.0-bin-hadoop2.7/examples/src/main/python/sql/streaming/structured_network_wordcount.py': [Errno 2] No such file or directory

但是我知道structured_network_wordcount.py文件在该位置。那为什么会出现这个错误呢?

0 个答案:

没有答案