In my main Python file, I import another script of mine called helper_1.py
(from the subfolder my_helpers
) like this:
from my_helpers.helper_1 as h1
However, when I now try to start my server (or deploy it to Heroku), the server will crash with the error notice:
ModuleNotFoundError: No module named 'my_helpers'
I do have a Procfile, requirements.txt, runtime.txt, and wsgi.py.
The content of my wsgi.py is:
from app.main import app
if __name__ == "__main__":
app.run()
MY QUESTION: Where and how do I have to declare my custom modules (own scripts) so they are properly detected when starting the Flask server?
Everything works fine if I leave out the external reference to my custom module.
CodePudding user response:
The folder my_helpers need to make it a package. To do this put inside the my_helpers a init.py file. This maybe fix your problem.