Apache spark 错误:必须指定主资源(JAR或Python或R文件)-IPython notebook

Apache spark 错误:必须指定主资源(JAR或Python或R文件)-IPython notebook,apache-spark,ipython,pyspark,Apache Spark,Ipython,Pyspark,我尝试在IPython笔记本中运行ApacheSpark,遵循以下说明(以及评论中的所有建议)—— 但当我通过以下命令运行IPython Notebook时: ipython notebook --profile=pyspark 我得到这个错误: Error: Must specify a primary resource (JAR or Python or R file) 如果我在shell中运行pyspark,一切正常。这意味着我在连接Spark和IPython时遇到了一些问题 顺便说一

我尝试在IPython笔记本中运行ApacheSpark,遵循以下说明(以及评论中的所有建议)——

但当我通过以下命令运行IPython Notebook时:

ipython notebook --profile=pyspark
我得到这个错误:

Error: Must specify a primary resource (JAR or Python or R file)
如果我在shell中运行pyspark,一切正常。这意味着我在连接Spark和IPython时遇到了一些问题

顺便说一下,这是我的bash_简介:

export SPARK_HOME="$HOME/spark-1.4.0"
export PYSPARK_SUBMIT_ARGS='--conf "spark.mesos.coarse=true" pyspark-shell'
其中包含~/.ipython/profile\u pyspark/startup/00 pyspark setup.py

# Configure the necessary Spark environment
import os
import sys

# Spark home
spark_home = os.environ.get("SPARK_HOME")

# If Spark V1.4.x is detected, then add ' pyspark-shell' to
# the end of the 'PYSPARK_SUBMIT_ARGS' environment variable
spark_release_file = spark_home + "/RELEASE"
if os.path.exists(spark_release_file) and "Spark 1.4" in  open(spark_release_file).read():
    pyspark_submit_args = os.environ.get("PYSPARK_SUBMIT_ARGS", "")
    if not "pyspark-shell" in pyspark_submit_args: pyspark_submit_args += " pyspark-shell"
    os.environ["PYSPARK_SUBMIT_ARGS"] = pyspark_submit_args

# Add the spark python sub-directory to the path
sys.path.insert(0, spark_home + "/python")

# Add the py4j to the path.
# You may need to change the version number to match your install
sys.path.insert(0, os.path.join(spark_home, "python/lib/py4j-0.8.2.1-src.zip"))

# Initialize PySpark to predefine the SparkContext variable 'sc'
execfile(os.path.join(spark_home, "python/pyspark/shell.py"))

还有可能需要的-昨天我将OS X升级到了10.10.4

我遇到了类似的问题,当与
spark-1.4.0
一起使用时,我使用了相同的
00 pyspark setup.py
文件

正如Philippe Rossignol关于, 以下行已添加到
00 pyspark setup.py
文件中 由于
pyspark\u SUBMIT\u ARGS
需要参数
pyspark shell

# If Spark V1.4.x is detected, then add ' pyspark-shell' to
# the end of the 'PYSPARK_SUBMIT_ARGS' environment variable
spark_release_file = spark_home + "/RELEASE"
if os.path.exists(spark_release_file) and "Spark 1.4" in open(spark_release_file).read():
    pyspark_submit_args = os.environ.get("PYSPARK_SUBMIT_ARGS", "")
    if not "pyspark-shell" in pyspark_submit_args: pyspark_submit_args += " pyspark-shell"
    os.environ["PYSPARK_SUBMIT_ARGS"] = pyspark_submit_args
但是,在我的
spark-1.4.0
文件夹中,没有
RELEASE
文件,因此将
pyspark外壳
附加到
pyspark提交参数
if
条件从未得到满足

作为一个笨拙的解决方案,我刚刚注释掉了检查发布文件的行,因此只剩下以下行:

pyspark_submit_args = os.environ.get("PYSPARK_SUBMIT_ARGS", "")
if not "pyspark-shell" in pyspark_submit_args: pyspark_submit_args += " pyspark-shell"
os.environ["PYSPARK_SUBMIT_ARGS"] = pyspark_submit_args

我会尝试设置spark之类的东西,而不是依赖博客上的帖子,告诉你以一种复杂的方式配置东西,这是不必要的,也不太灵活。无论如何,谢谢你@马特,我希望我能给你5票以上的意见。我试过很多博客帖子和新的Toree项目,都经历了不同程度的痛苦,但都没有成功。有了findspark,MinRK再次提供了一个简单易用的伟大解决方案。