Forums

Flask - ModuleNotFoundError: No module named ...

Hello all, I have the following project structure running with Flask: https://imgur.com/9qD3sau

Inside update_lines.py I do the following: https://imgur.com/CCXTQw7

This is my WSGI file configuration for this project: https://imgur.com/rnr8raU

When I try to run the lines_update.py file inside the flask application, I get the following error:

2018-09-18 12:40:24,877: Error running WSGI application
2018-09-18 12:40:24,878: ModuleNotFoundError: No module named 'common'
2018-09-18 12:40:24,878:   File "/var/www/mapmanaus_pythonanywhere_com_wsgi.py", line 16, in <module>
2018-09-18 12:40:24,879:     from core import app as application  # noqa
2018-09-18 12:40:24,879: 
2018-09-18 12:40:24,879:   File "/home/mapmanaus/wm-backend/core.py", line 5, in <module>
2018-09-18 12:40:24,879:     from tasks.update_lines import vf_retrieve_workgroups
2018-09-18 12:40:24,879: 
2018-09-18 12:40:24,879:   File "/home/mapmanaus/wm-backend/tasks/update_lines.py", line 15, in <module>
2018-09-18 12:40:24,879:     from common import vf_login

Could anyone please help me? I believe I must be forgetting some configuration for the import structure. Thanks!

sys.path.append can't take a relative path. make it a full (absolute) path. See this