Reputation: 10033
This is my project structure:
maths/
__init__.py
trig.py
coord.py
pitch.py
models/
__init__.py
model.py
In model.py
, I have:
import sys
sys.path.append("../")
from maths.pitch import *
if __name__ == "__main__":
# my routines
In pitch.py
, I have:
from trig import calculate_distance_angles
When I run model.py
, I'm getting the error:
File "model.py", line 38, in <module>
from maths.pitch import *
File "../maths/pitch.py", line 9, in <module>
from trig import calculate_distance_angles
ModuleNotFoundError: No module named 'trig'
How do I fix this?
Upvotes: 0
Views: 161
Reputation: 679
The error came from here: from trig import calculate_distance_angles
. I suppose you are looking for your maths/trig.py
file:
maths/
__init__.py
trig.py <-- this one
coord.py
pitch.py
models/
__init__.py
model.py
On your sys.path
, you may have this:
sys.path
stuff)..."../"
(added at model.py
)But the maths
model, as far as we can see, is not on sys.path
. If that's true, you may have to modify the import as follows. This should work:
from maths.trig import calculate_distance_angles
Upvotes: 4