Issue
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.
Solution
The folder my_helpers needs to be a package. To do this put an __init__.py
file inside the my_helpers
folder. This maybe fix your problem.
Answered By - nicktehboy meny
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.