2016-04-11 11 views
0

Ich habe einen Pyspark-Job (Spark 1.6.1, Python 2.7). Die Grundstruktur ist:Modul ImportError mit PySpark

spark_jobs/ 
    __init__.py 
    luigi_workflow.py 
    my_pyspark/ 
    __init__.py 
    __main__.py 
    spark_job.py 
    stuff/ 
     __init__.py 
     module1.py 
     module2.py 
    analytics/ 
     __init__.py 
     analytics.py 

In meinem spark_job.py ich habe:

from dir1.module1 import func1 
from dir1.module2 import func2 
from analytics.analytics import some_analytics_func 
... 
func1(...) 
func2(...) 
some_analytics_func(...) 
... 

Wenn ich den Funken Job starten, func1 und func2 perfekt ausführen, aber dann bekomme ich:

ImportError: No module named analytics.analytics

Das hat mich absolut verrückt gemacht. Jede Hilfe wäre willkommen.

Hinweis: Ich bin um spark-submit mit einem Wrapper startet und den Pfad mit python -m spark_jobs.my_pyspark

Antwort

0

Ich verstehe nicht benannt, wo dir1 herkommt? Sollte es nicht from my_pyspark.stuff.module1 import func1 sein? Hast du das schon mal probiert? from my_pyspark.analytics.analytics import some_analytics_func? Da Sie Luigi verwenden, können Sie auch versuchen, das Paket über setup.py zu erstellen.

Hoffe, das hilft! Ich hatte diese Probleme vorher aber es kann gelöst werden.