I am having a problem importing a script in another directory to the main script. FYI, this is a python Flask app. I have the empty __init__.py
in the module_directory, so importing the module in the upper __init__.py
should not be a problem, but it happens. I don't know why.
myfolder
- __init__.py
- module_directory
- script_to_import.py
- __init__.py
- static
- templates
__init__.py
is the main server script where the app is defined with routes like @app.route("/home", methods=["GET","POST"])
something like that.
Below is what I do in the upper __init__.py
to import the module.
from module_directory.script_to_import import *
It gives me error saying that No module_directory
.
putting . in front of the module name fixed the problem.
from .module_directory.script_to_import import *