Reputation: 23
I have python project like
/project
|__main.py
|__/graph
|____grapher.py
|____object_map_genaration.py
import object_map_genaration
import grapher
But I got this error:
ModuleNotFoundError: No module named 'object_map_genaration'
Upvotes: 0
Views: 50
Reputation: 1314
First add an init here:
/project/
|__/main.py
|__/graph/
|____/__init__.py
|____/grapher.py
|____/object_map_genaration.py
Then in grapher.py:
from . import object_map_genaration
And in main.py:
from graph import grapher
Upvotes: 2
Reputation: 2602
You need from grapher import object_map_genaration
not just import object_map_genaration
, since imports are relative to the root of the main file.
Upvotes: 1