简体   繁体   English

使用Spark在python中运行独立应用程序示例时出错

[英]Error while running standalone app example in python using spark

I am just getting started on spark and am running it on standalone mode over amazon EC2 instance. 我刚刚开始使用Spark,并在Amazon EC2实例上以独立模式运行它。 I was trying examples mentioned in the documentation and while going through this example called Simple App I keep getting this error: NameError: name 'numAs' is not defined 我正在尝试文档中提到的示例,并且在浏览名为Simple App的示例时,我不断收到此错误:NameError:未定义名称'numAs'

from pyspark import SparkContext

logFile = "$YOUR_SPARK_HOME/README.md"  # Should be some file on your system
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)

How do I integrate an editor into spark instead of using this dynamic python shell? 如何将编辑器集成到spark中而不使用此动态python shell? Why do I keep getting this error? 为什么我不断收到此错误?

Thanks for any help/guidance. 感谢您的帮助/指导。

put your all your python code in a .py file , then submit the .py file like below: 将您所有的python代码放入.py文件 ,然后提交.py文件,如下所示:

# Run a Python application on a Spark Standalone cluster
./bin/spark-submit \
  --master spark://207.184.161.138:7077 \
  examples/src/main/python/pi.py \
  1000

read here: 在这里阅读:

Submitting Applications 提交申请

try these examples, really helping: 试试这些例子,确实有帮助:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM