2015-07-02 7 views
7

Ich versuche, Apache Spark in IPython Notebook zu laufen, folgen Sie diesem insruction (und alle Tipps in den Kommentaren) - linkFehler: Es muss eine primäre Ressource (JAR oder Python oder R-Datei) angeben - IPython Notebook

Aber als ich laufen IPython Notebook mit diesem Befehl:

ipython notebook --profile=pyspark 

ich diesen Fehler:

Error: Must specify a primary resource (JAR or Python or R file) 

Wenn ich pyspark in Shell ausgeführt, alles in Ordnung. Das bedeutet, dass ich Probleme mit der Verbindung Spark und IPython habe.

By the way, das ist mein bash_profile:

export SPARK_HOME="$HOME/spark-1.4.0" 
export PYSPARK_SUBMIT_ARGS='--conf "spark.mesos.coarse=true" pyspark-shell' 

Und diese enthalten ~/.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")) 

Und was kann notwendig sein - gestern habe ich mein OS X auf 10.10.4 aktualisiert

+1

Ich würde Dinge versuchen, wie https://pypi.python.org/pypi/findspark um einen Funken zu setzen, statt sich auf einen Blog-Beitrag zu verlassen, der Ihnen sagt, dass Sie Dinge auf eine komplexe Weise konfigurieren müssen, die nicht notwendig und weniger flexibel ist. – Matt

+0

Also, ich versuche es, aber es hilft nicht. Trotzdem danke! –

+0

@Matt Ich wünschte, ich könnte Ihren Kommentar 5 upvotes geben. Ich habe viele der Blogposts und das neue Toree-Projekt mit unterschiedlichem Schmerz und wenig Erfolg ausprobiert. Mit Findspark kommt wieder MinRK mit einer großartigen Lösung, die einfach zu bedienen ist. – MarkNS

Antwort

8

Ich hatte ein ähnliches Problem und ich verwendete die gleiche 00-pyspark-setup.py Datei, wenn mitverwendet.

Wie von den Kommentaren von Philippe Rossignol auf this blog, die folgenden Zeilen in die 00-pyspark-setup.py Datei hinzugefügt wurden, da das Argument pyspark-shell für PYSPARK_SUBMIT_ARGS benötigt wird:

# 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 

jedoch in meinem spark-1.4.0 Ordner, war es keine RELEASE Datei, so dass die if Bedingung an pyspark-shell zu PYSPARK_SUBMIT_ARGS anhängen nie erfüllt wurde.

Als kludgy Lösung, die ich nur die Linien, die die Release-Datei, so die Überprüfung auf Kommentar nur die folgenden Zeilen vorhanden sind:

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