I've been fighting with this for weeks, read so many (outdated) articles, tried so many different proposed solutions without success. And I still believe I'm not trying to do something difficult...
I have the following folder structure
├── script.py
├── lib
│ ├── lonlatboxes.py
│ ├── utils.py
I'm using the folder lib
to store some libraries used in script.py
.
In utils.py
I have
from sqlalchemy import create_engine # python package
from lonlatboxes import lonlatboxes # my module
In lonlatboxes.py
I have
lonlatboxes = {
'Africa': [-26.0, 63.0, -41.0, 37.0],
}
In script.py
I do
import lib.utils
And this causes an error
1 from sqlalchemy import create_engine
----> 2 from lonlatboxes import lonlatboxes
3
ModuleNotFoundError: No module named 'lonlatboxes'
I guess because the sys.path
is resolved w.r.t. the parent folder and not lib
. Note that the lib.utils
file is found!
How should I solve this? Or...am I doing something completely against Python imports?
I believe adding the path to sys.path
should not be the correct solution.
Note that I DON'T want to create a package. I just have a set of scripts and small libraries and want to avoid to put everything into the same folder and instead keep them separated so that I can have more order :)