Access to Spark from Flask app

后端 未结 3 1092
深忆病人
深忆病人 2021-02-02 02:31

I wrote a simple Flask app to pass some data to Spark. The script works in IPython Notebook, but not when I try to run it in it\'s own server. I don\'t think that the Spark co

3条回答
  •  鱼传尺愫
    2021-02-02 02:57

    I was able to fix this problem by adding the location of PySpark and py4j to the path in my flaskapp.wsgi file. Here's the full content:

    import sys
    sys.path.insert(0, '/var/www/html/flaskapp')
    sys.path.insert(1, '/usr/local/spark-2.0.2-bin-hadoop2.7/python')
    sys.path.insert(2, '/usr/local/spark-2.0.2-bin-hadoop2.7/python/lib/py4j-0.10.3-src.zip')
    
    from flaskapp import app as application
    

提交回复
热议问题