2016-07-18 51 views
0

我已经在Java/Scala中做了相当多的点火工作,我可以直接从main()程序运行一些测试点火工作,只要我在maven pom.xml。pycharm:我如何将pyspark导入pycharm

现在我开始与pyspark合作。我想知道我是否可以做类似的事情?例如,我使用pycharm运行中的wordCount工作:

enter image description here

如果我只是运行main()程序,我得到了以下错误:

Traceback (most recent call last): 
    File "/Applications/PyCharm.app/Contents/helpers/profiler/run_profiler.py", line 145, in <module> 
    profiler.run(file) 
    File "/Applications/PyCharm.app/Contents/helpers/profiler/run_profiler.py", line 84, in run 
    pydev_imports.execfile(file, globals, globals) # execute the script 
    File "/Users/edamame/PycharmProjects/myWordCount/myWordCount.py", line 6, in <module> 
    from pyspark import SparkContext 
ImportError: No module named pyspark 

Process finished with exit code 1 

我想知道如何我在这里进口pyspark吗?所以我可以像在Java/Scala中那样从main()程序运行一些测试工作。

我也尝试过编辑解释道: enter image description here

和我的截图,从运行 - >编辑配置:

enter image description here

最后是我的项目结构的屏幕截图: enter image description here

我错过了什么吗?谢谢!

+1

看起来你缺少pyspark模块? –

+1

[PyCharm与PySpark的联系如何?]可能的重复(http://stackoverflow.com/questions/34685905/how-to-link-pycharm-with-pyspark) –

+0

@ cricket_007:我修改了上面的问题。我试图“编辑解释器路径,所以它包含到$ SPARK_HOME/python的路径”,如“如何将PyCharm与PySpark链接?”中所述,但我无法找到编辑解释器路径的位置......我在这里丢失了什么?谢谢 – Edamame

回答

0

我加入了py4j-xxx-src.zip和pyspark.zip在$ SPARK_HOME/Python的/ lib目录的项目结构(首选项>项目>项目结构,然后做 “+添加内容根” ),它工作得很好。

PS:Pycharm已经有$ PYTHONPATH,而从OS ENV读$ SPARK_HOME,这是在.bashrc中设置/ .bash_profile中