The file structure of the code I am working with right now is as follows:
school_project/
__init__.py #(empty)
main_functions/
__init__.py #(empty)
render.py
filter.py
helper_functions/
__init__.py #(empty)
string.py
utility.py
Currently, I need to use functions founded in utility.py
in the file render.py
. My first attempt at solving this problem was to do import ..helper_functions.utility
in the file render.py
.
Unfortunately, it was met with the following error message.
import ..helper_functions.utility
^
SyntaxError: invalid syntax
First off, I have no idea why this relative import is not working.
Secondly, should I just use an absolute import instead? In the form import school_project.helper_functions.utility
? If so, would I then need to add the directory that school_project/
is currently in to PYTHONPATH? How would I do this?
Would I just modify my computer's PATH and PYTHONPATH will adapt accordingly? Or are they separate entities and the process is a bit more involved? Ive looked at other threads but they all seem to modify PYTHONPATH at run time in the python script itself, something I see as a giant potential origin of bugs in the future.