Pycharm上运行spark2.1自带的例子(basic.py)报AttributeError: 'function' obj...
"""SimpleApp"""from pyspark import SparkContext
from pyspark.streaming.kafka import KafkaUtils
logFile = "C:\spark-2.1.0-bin-hadoop2.7\README.md"
sc = SparkContext("local","Simple App")
logData = sc.textFile(logFile).cache()
numAs = logData.filter(lambda s: 'a' in s).count()
numBs = logData.filter(lambda s: 'b' in s).count()
print("Lines with a: %i, lines with b: %i"%(numAs, numBs))
本人运行这个没有问题。但是运行basic.py直接报错
C:\Users\John\AppData\Local\Programs\Python\Python35\python.exe C:/Users/John/PycharmProjects/hellworld/test2.py
Traceback (most recent call last):
File "C:/Users/John/PycharmProjects/hellworld/test2.py", line 218, in <module>
basic_df_example(spark)
File "C:/Users/John/PycharmProjects/hellworld/test2.py", line 45, in basic_df_example
df = spark.read.json("C:\spark-2.1.0-bin-hadoop2.7\examples\src\main\resources\people.json")
AttributeError: 'function' object has no attribute 'read'
Process finished with exit code 1
补充下,使用的是Python3.5.2版本 hote123456 发表于 2017-2-15 14:19
补充下,使用的是Python3.5.2版本
df = spark.read.json("C:\spark-2.1.0-bin-hadoop2.7\examples\src\main\resources\people.json")
上面spark是什么?他可能没有这个属性
已经搞定,字符集问题
页:
[1]