未定义名称spark [英] name spark is not defined

查看:93
本文介绍了未定义名称spark的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试遵循spark教程,但出现以下错误-

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

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

未定义名称火花""

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

这就是我的开始方式-

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

推荐答案

如果您的Spark版本是1.0.1,则不应使用本教程的2.2.0版本.这些版本之间有重大变化.

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.

在此网站上,您可以找到 1.6.0教程.

On this website you can find the Tutorial for 1.6.0 .

在1.6.0教程之后,您必须使用 textFile = sc.textFile("README.md")而不是 textFile = spark.read.text("README.md").

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

这篇关于未定义名称spark的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆