title: sc._jvm.org.apache.spark.streaming.kafka.KafkaUtilsPythonHelper() TypeError: 'JavaPackage' object is not callable when using
body: <p>I am learning how to integrate <code>spark</code> with <code>kafka</code>. Currently i created a <code>virtualenv</code> and installed <code>pyspark</code>, <code>py4j</code> packages.</p>
  
  <p>I also configured these environment:</p>
  
  <ol>
  <li>PYSPARK_PYTHON  :  <code>C:\learn_new\learn_utils\venv\Scripts\python.exe</code></li>
  <li>SPARK_HOME      :  <code>C:\spark-2.4.3-bin-hadoop2.7</code></li>
  </ol>
  
  <p>Then i want to run the example python source code under <code>C:\spark-2.4.3-bin-hadoop2.7\examples\src\main\python\streaming\direct_kafka_wordcount.py</code></p>
  
  <p>The script code is this:</p>
  
  <pre><code>    from __future__ import print_function
      import sys
  
  
      from pyspark import SparkContext
      from pyspark.streaming import StreamingContext
      from pyspark.streaming.kafka import KafkaUtils
  
  
      if __name__ == "__main__":
          if len(sys.argv) != 3:
              print("Usage: direct_kafka_wordcount.py &lt;broker_list&gt; &lt;topic&gt;", file=sys.stderr)
          sys.exit(-1)
  
      sc = SparkContext(appName="PythonStreamingDirectKafkaWordCount")
      ssc = StreamingContext(sc, 2)
  
      brokers, topic = sys.argv[1:]
      kvs = KafkaUtils.createDirectStream(ssc, [topic], {"metadata.broker.list": brokers})
      lines = kvs.map(lambda x: x[1])
      counts = lines.flatMap(lambda line: line.split(" ")) \
          .map(lambda word: (word, 1)) \
          .reduceByKey(lambda a, b: a+b)
      counts.pprint()
  
      ssc.start()
      ssc.awaitTermination()
  </code></pre>
  
  <p>The command line to run the python code under <code>virtualenv</code> is this:</p>
  
  <pre><code>python --default --client --host localhost --port 60614 c:\spark-2.4.3-bin-hadoop2.7\examples\src\main\python\streaming\direct_kafka_wordcount.py kafka_host_name:9092 topic_name
  </code></pre>
  
  <p>Then i got this error:</p>
  
  <pre><code>    File "c:\spark-2.4.3-bin-hadoop2.7\examples\src\main\python\venv\lib\site-packages\pyspark\streaming\kafka.py", line 138, in createDirectStream
          helper = KafkaUtils._get_helper(ssc._sc)
      File "c:\spark-2.4.3-bin-hadoop2.7\examples\src\main\python\venv\lib\site-packages\pyspark\streaming\kafka.py", line 217, in _get_helper
          return sc._jvm.org.apache.spark.streaming.kafka.KafkaUtilsPythonHelper()
      TypeError: 'JavaPackage' object is not callable
  </code></pre>
  
  <p>What's the issue of it?
  Thanks very much.</p>