I have been trying to migrate my flask application to AWS using ElasticBeanStalk. The migration goes fine, however the site gives 500 error. The error log of the website shows as follows:
[Sat Dec 08 12:49:50.082687 2018] [:error] [pid 3996] [remote 37.37.41.199:176] mod_wsgi (pid=3996): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Sat Dec 08 12:49:50.082780 2018] [:error] [pid 3996] [remote 37.37.41.199:176] Traceback (most recent call last):
[Sat Dec 08 12:49:50.082805 2018] [:error] [pid 3996] [remote 37.37.41.199:176] File "/opt/python/current/app/application.py", line 10, in <module>
[Sat Dec 08 12:49:50.082808 2018] [:error] [pid 3996] [remote 37.37.41.199:176] from KoreD import app ##### Main Project Package ######
[Sat Dec 08 12:49:50.082814 2018] [:error] [pid 3996] [remote 37.37.41.199:176] File "/opt/python/current/app/KoreD/__init__.py", line 4, in <module>
[Sat Dec 08 12:49:50.082816 2018] [:error] [pid 3996] [remote 37.37.41.199:176] from flask import Flask
[Sat Dec 08 12:49:50.082830 2018] [:error] [pid 3996] [remote 37.37.41.199:176] ModuleNotFoundError: No module named 'flask'
However when i use SSH to login into the EC2 instance and navigate to the virtualenv and try to install flask it shows that flask is already installed. I have been on to it for quite sometime to figure out, and it seems to be not going through. Any suggestions would be appreciated.
Error shows flask missing and installed
I ran which flask and which python commands to determine the path and the results as follows:
Python and flask path
Is there a possibility for it to be Path issue, if so how would that be fixed?
It seems like python
command not from your virtual environment. Flask was installed to /usr/local/lib64/python3.6/site-packages, but not in your virtualenv.
Please be sure you used correct python executable from your virtual environment.
Probably you should recreate your virtual environment, to do that you should run python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With