Hi,
I am new to pythonanywhere and I have a problem with deploying my flask app. error log:
2018-08-27 08:31:14,236: Error running WSGI application
2018-08-27 08:31:14,242: ImportError: cannot import name 'db'
2018-08-27 08:31:14,243: File "/var/www/lukaszgg_pythonanywhere_com_wsgi.py", line 16, in <module>
2018-08-27 08:31:14,243: from todo_app import app as application # noqa
2018-08-27 08:31:14,243:
2018-08-27 08:31:14,243: File "/home/Lukaszgg/todo_list/todo_app.py", line 3, in <module>
2018-08-27 08:31:14,243: import views
2018-08-27 08:31:14,243:
2018-08-27 08:31:14,244: File "/home/Lukaszgg/todo_list/views.py", line 1, in <module>
2018-08-27 08:31:14,244: import models
2018-08-27 08:31:14,244:
2018-08-27 08:31:14,244: File "/home/Lukaszgg/todo_list/models.py", line 1, in <module>
2018-08-27 08:31:14,244: from todo_app import db
2018-08-27 08:31:14,244: ***************************************************
2018-08-27 08:31:14,245: If you're seeing an import error and don't know why,
2018-08-27 08:31:14,245: we have a dedicated help page to help you debug:
2018-08-27 08:31:14,245: https://help.pythonanywhere.com/pages/DebuggingImportError/
2018-08-27 08:31:14,245: ***************************************************
db var is defined in todo_app. My lukaszgg_pythonanywhere_com_wsgi.py:
import sys
# add your project directory to the sys.path
project_home = u'/home/Lukaszgg/todo_list/'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# import flask app but need to call it "application" for WSGI to work
from todo_app import app as application # noqa
if I try to run in console:
python todo_app.py
from /home/Lukaszgg/todo_list/directory there is no import error. Also, locally is everything ok. But if I try to run in console:
python lukaszgg_pythonanywhere_com_wsgi.py
from /var/www/ directory above error is occurred. I tried different python versions configured on Web tab with and without virtual env. Please help me with it.