How to solve import errors while trying to deploy Flask using WSGI on Apache2

后端 未结 2 1166
小蘑菇
小蘑菇 2020-12-13 18:09

I am having an issue deploying a flask app on apache2 using wsgi. I have posted the error logs and config files below. I have tried moving things around, renaming them, etc,

相关标签:
2条回答
  • 2020-12-13 18:43

    Thanks to zarf and damjan on irc.freenode.org at #pocoo, they were able to help me get this fixed. The problem was the PythonPath was not correct. We fixed this by using the following wsgi.py

    import sys
    sys.path.insert(0, "/sites/flaskfirst")
    
    from app import app
    application = app
    
    0 讨论(0)
  • 2020-12-13 19:02

    I used your solution to get it working but it kept duplicating the path in sys.path (you can write it out to see if it happens to you) so I made a little modification:

    import sys
    flaskfirst = "/sites/flaskfirst"
    if not flaskfirst in sys.path:
        sys.path.insert(0, flaskfirst)
    
    from app import app
    application = app
    

    That way it's only included once

    0 讨论(0)
提交回复
热议问题