gpt4 book ai didi

apache-spark - 错误 : Must specify a primary resource (JAR or Python or R file) - IPython notebook

转载 作者:行者123 更新时间:2023-12-04 05:05:49 25 4
gpt4 key购买 nike

我尝试在 IPython Notebook 中运行 Apache Spark,请遵循此说明(以及评论中的所有建议)- link

但是当我通过这个命令运行 IPython Notebook 时:

ipython notebook --profile=pyspark

我收到此错误:
Error: Must specify a primary resource (JAR or Python or R file)

如果我在 shell 中运行 pyspark,一切正常。这意味着我在连接 Spark 和 IPython 时遇到了一些麻烦。

顺便说一下,这是我的 bash_profile:
export SPARK_HOME="$HOME/spark-1.4.0"
export PYSPARK_SUBMIT_ARGS='--conf "spark.mesos.coarse=true" pyspark-shell'

这包含 ~/.ipython/profile_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

最佳答案

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

正如 Philippe Rossignol 在 this blog 上的评论所解释的那样,
以下几行被添加到 00-pyspark-setup.py文件
由于参数pyspark-shell需要 PYSPARK_SUBMIT_ARGS :

# 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文件,所以 if要附加的条件 pyspark-shellPYSPARK_SUBMIT_ARGS从未满足。

作为一个笨拙的解决方案,我只是注释掉了检查发布文件的行,所以只剩下以下几行:
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

关于apache-spark - 错误 : Must specify a primary resource (JAR or Python or R file) - IPython notebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31193768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com