Issue with imports when using WSGI in EC2 Instance to Host Flask App

喜欢而已 提交于 2019-11-29 16:20:32

You must set:

WSGIApplicationGroup %{GLOBAL}

in mod_wsgi configuration when using numpy and related packages. If you don't it can hang because numpy has not been implemented in a way that it will work in Python sub interpreters.

See:

After a long and painful exercise, I was able to finally get my app running .The issue is with the pandas 0.19.2 built when the application is getting imported in the .wsgi file

To resolve it Remove your imports from the global level and insert them at the function level

import pandas as pd
....
@app.route('/getFunction', methods=["GET"])
def sample_get_function():
    movieData=pd.read_csv('someData.csv')

to

....
@app.route('/getFunction', methods=["GET"])
def sample_get_function():
    import pandas as pd
    movieData=pd.read_csv('someData.csv')

This is not a very good solution but it is working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!