I have this directory structure
- folder
- measuring_scripts
measure_something.py
- analysis_scripts
plot_measured.py
- measuring_scripts
I want to import a function from plot_measured.py
into measure_something.py
. So measure_something.py
begins like this
PATH_TO_ANALYSIS_SCRIPTS = Path(__file__).resolve().parent.parent/'analysis_scripts'
print(PATH_TO_ANALYSIS_SCRIPTS)
import sys
sys.path.append(PATH_TO_ANALYSIS_SCRIPTS)
from plot_measured import something
# More stuff
This prints
/home/someone/blah/folder/analysis_scripts
Traceback (most recent call last):
File "measure_something.py", line 5, in <module>
from plot_measured import something
ModuleNotFoundError: No module named 'plot_measured'
How can I do this? I tried converting analysis_scripts
into a module adding the __init__.py
file and changing to from analysis_scripts.plot_measured import something
but it is the same.
I know this has been asked a million times. I have myself even done this thousands of times in the past, but cannot see where I am failing this time...