Numpy ImportError when deploying Flask App using mod_wsgi/Apache2

后端 未结 2 413
难免孤独
难免孤独 2021-01-19 07:43

I\'m trying to get a Flask app running on AWS EC2 (standard Ubuntu AMI) through an Apache2 Webserver. My app internally uses Numpy. I have tested the following:

相关标签:
2条回答
  • 2021-01-19 08:17

    This:

    site.addsitedir('/home/ubuntu/.local/lib/python2.7/site-packages/numpy')
    

    should have been:

    site.addsitedir('/home/ubuntu/.local/lib/python2.7/site-packages')
    

    But the whole way you are setting up Python virtual environments is not best practice anyway. Suggest you read:

    • http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html

    Also try and switch to daemon mode, it is better to use daemon mode than embedded mode.

    0 讨论(0)
  • 2021-01-19 08:30

    numpy via pip is not installed at /home/ubuntu/.local/lib/python2.7/site-packages but it should be at /home/ubuntu/.local/lib64/python2.7/site-packages or something like that.

    Just try add another site.addsitedir in your app.wsgi to that folder should work. Something like this :

    site.addsitedir('/home/ubuntu/.local/lib64/python2.7/site-packages')

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