I have a folder directory that looks as such:
-- show_case
--airflow
--dags
fundamental_data_pipeline.py
__init__.py
financials_api_get.py
I am trying to run a function get_fundemental_data from financial_api_get.py within fundamental_data_pipeline.py but I get an import error.
My file fundamental_data_pipeline.py looks like this:
sys.path.insert(1, Path(__file__).resolve().parent.parent.parent)
print(Path(__file__).resolve().parent.parent.parent)
from financials_api_get import get_fundemental_data
A print of the path prints show_case but I still get
ModuleNotFoundError: No module named 'financials_api_get'
Why doesn't this work?
EDIT
I have an __init__.py file that looks as such:
from financials_api_get import get_fundemental_data
Problem is
Pathbecausesys.pathexpects onlystrings.If you run
print(sys.path)then you should see[Path(...), ...]So you may need
str()or
.as_posix()