I am trying to import a module (not a file) from a different path.
By module, I mean that I have a folder named Util
containing a single file named __init__.py
.
Using import Util
in a python file on the same level as the Util
folder works fine.
But this is not the case when the python file resides elsewhere.
Following this answer, I have this piece of code working:
import sys,os
sys.path.append(os.path.dirname(__file__)+'the relative path to the python file that I want to import')
But it works only when I import a python file, not a python module.
How can I resolve this?