pyspark'sparksession'对象没有属性'\u jssc'

vshtjzan  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(561)

我正在使用:hadoop 2.6.0-cdh5.14.2 spark2-2.3.0.cloudera2-1.cdh5.13.3.p0.316101
当我从kafkautils启动directstream时,出现了一个错误:

File "/home/ale/amazon_fuse_ds/bin/hdp_amazon_fuse_aggreagation.py", line 91, in setupContexts
kafka_stream = KafkaUtils.createDirectStream( self.spark_streaming_context, [ self.kafka_topicin ], kafka_configuration )
  File "/opt/cloudera/parcels/SPARK2-2.3.0.cloudera2-1.cdh5.13.3.p0.316101/lib/spark2/python/lib/pyspark.zip/pyspark/streaming/kafka.py", line 145, in createDirectStream
 AttributeError: 'SparkSession' object has no attribute '_jssc'

我看到sparksession有jsc方法,但是jssc。

nxowjjhe

nxowjjhe1#

你经过的物体是 SparkSession ,你为什么要通过 StreamingContext .

from pyspark.streaming import StreamingContext

ssc = StreaminContext(self.spark_streaming_context.sparkContext, batchDuration)
KafkaUtils.createDirectStream(ssc, ...)

相关问题