2017-08-05 78 views
0

我在PyCharm上編寫了一個名爲Wordcount.py的python文件。 這是Wordounct.py在Pycharm上使用python執行spark程序時遇到錯誤

import sys,os from pyspark import SparkContext 
sc = SparkContext() 
myrdd = sc.textFile("passwd") 
myrdd.count() 

當我運行它的內容,我中遇到上控制檯

顯示一個錯誤以下是錯誤信息

/usr/local/bin/python3 /home/plters/PycharmProjects/Spark21/Wordcount.py 
Traceback (most recent call last): 
    File "/home/plters/PycharmProjects/Spark21/Wordcount.py", line 2, in <module> 
    from pyspark import SparkContext 
    File "/opt/spark2/python/pyspark/__init__.py", line 44, in <module> 
    from pyspark.context import SparkContext 
    File "/opt/spark2/python/pyspark/context.py", line 29, in <module> 
    from py4j.protocol import Py4JError 
ImportError: No module named 'py4j 

我應該怎麼辦?

回答

1

看起來py4j模塊丟失,從終端只需安裝

pip install py4j 
相關問題