I have a python project using Flask and I have a form I have setup in a module I called forms. I test my app in Windows and it works just fine. I then update my project on Debian where I use Apache2 to run the project. There I get the error: ModuleNotFoundError: No module named 'forms'
My project is organized like so:
flaskapp.wsgi
flask_app
__init__.py
forms.py
And __init__.py starts with:
from flask import Flask, redirect, url_for, request, render_template, send_from_directory, abort
from requests import Request, Session
from forms import OrderForm
I checked the sys.path with:
import sys
print(sys.path)
when using the python console and got:
['', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']
I’m not sure what I need to do to get it to use forms as a module
>Solution :
Try from .forms import OrderForm.
This is referencing to the same folder. Otherwise flask_app.forms should work too.