name spark is not defined

耗尽温柔 提交于 2019-12-24 08:15:15

问题


Trying to follow the spark tutorial but get the following error -

https://spark.apache.org/docs/latest/quick-start.html

"name 'spark' is not defined"

Using Python version 2.6.6 (r266:84292, Nov 22 2013 12:16:22)
SparkContext available as sc.
>>> import pyspark
>>> textFile = spark.read.text("README.md")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'spark' is not defined

This is how I start it -

./bin/pyspark --master local[*]

回答1:


If your spark version is 1.0.1 you should not use the tutorial for version 2.2.0. There are major changes between these versions.

On this website you can find the Tutorial for 1.6.0 .

Following the 1.6.0 tutorial you have to use textFile = sc.textFile("README.md") instead of textFile = spark.read.text("README.md").



来源:https://stackoverflow.com/questions/46179350/name-spark-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!