如何使用Python在Eclipse中调用SparkContext和SparkConf

时间:2015-11-12 19:40:15

标签: python-2.7 apache-spark apache-spark-1.5

我在Eclipse IDE中配置了PySpark环境。我挂载了Py4J驱动程序,链接了PyDev解释器,并通过环境变量设置了PySpark目录,但我对如何创建SparkConf对象以设置setAppName和setMaster配置感到困惑。我在Mac上使用Python版本2.7.10。我还查看了来自here的Stack Overflow问题。

以下是代码:

from pyspark import SparkConf, SparkContext

sparkConf = (SparkConf()
     .setMaster("local")
     .setAppName("My app"))
sc = SparkContext(conf = sparkConf)

当我调试第3行时,引发以下几个例外:

  

追踪(最近一次通话):     File" /Users/admin/Downloads/Eclipse.app/Contents/Eclipse/plugins/org.python.pydev_4.4.0.201510052309/pysrc/pydevd.py" ;, line 2364,in       globals = debugger.run(setup [' file'],None,None,is_module)     文件" /Users/admin/Downloads/Eclipse.app/Contents/Eclipse/plugins/org.python.pydev_4.4.0.201510052309/pysrc/pydevd.py" ;,第1784行,在运行中       pydev_imports.execfile(文件,全局,本地)#执行脚本     文件" /Users/admin/Documents/workspace/parsingData/visual_data/src/WordCounts.py" ;,第27行,在       sc = SparkContext(conf = SparkConf())     文件" /Users/admin/Downloads/spark-1.5.1/python/pyspark/conf.py",第104行, init       SparkContext._ensure_initialized()     文件" /Users/admin/Downloads/spark-1.5.1/python/pyspark/context.py" ;,第234行,在_ensure_initialized中       SparkContext._gateway = gateway或launch_gateway()     文件" /Users/admin/Downloads/spark-1.5.1/python/pyspark/java_gateway.py",第76行,在launch_gateway中       proc = Popen(命令,stdin = PIPE,preexec_fn = preexec_func,env = env)     文件" /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py" ;,第710行, init       errread,errwrite)     文件" /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",第1335行,在_execute_child中       提出child_exception   OSError:[Errno 2]没有这样的文件或目录

提前致谢。

0 个答案:

没有答案