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?
CodePudding user response:
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:
- (all the original
sys.pathstuff)... "../"(added atmodel.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
CodePudding user response:
u should run it as a module python -m
