kedro.framework.context.context.KedroContextError with Kedro 0.17.0
See original GitHub issueDescription
Short description of the problem here. I kept facing the ModuleNotFoundError then came across this post about the similar issue. Further after implementing the recommended solution (snipet below), I got this error:
_add_src_to_path(Path.cwd()/“src”, Path.cwd()) context = load_context(path_to_project) output = context.run()
Context
How has this bug affected you? What were you trying to accomplish? I was trying to deploy the kedro application on Docker using flask API. But the error occured while implementing the Flask API
Steps to Reproduce
- [Create the flask python file] I created the python file containing my flask scripts with the useful imports. Everything works fine while using the default route to test the Flask API Everything breaks when I call the load_context(path_to_project) (snipet below)
@app.route(‘/run’) def run(): _add_src_to_path(Path.cwd()/“src”, Path.cwd()) context = load_context(path_to_project) output = context.run() return output
- [Call the run route] Got the kedro.framework.context.context.KedroContextError with the following detail: kedro.framework.context.context.KedroContextError: Failed to find the pipeline named ‘default’. It needs to be generated and returned by the ‘_get_pipelines’ function.
Expected Result
I should receive a JSON outpout showing: {“Model has a coefficient R^2 of 0.456.”}
Actual Result
I face the error explained in step 2. [Call the run route]
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/kedro/framework/context/context.py", line 253, in _get_pipeline
return pipelines[name]
KeyError: '__default__'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/zoumanakeita/Desktop/Personal/Learn_Kedro/iris-kedro/flask-app.py", line 16, in run
output = context.run()
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/kedro/framework/context/context.py", line 561, in run
pipeline = self._get_pipeline(name=pipeline_name)
File "/Users/zoumanakeita/opt/anaconda3/envs/awesome-kedro-project-env/lib/python3.7/site-packages/kedro/framework/context/context.py", line 259, in _get_pipeline
) from exc
kedro.framework.context.context.KedroContextError: Failed to find the pipeline named '__default__'. It needs to be generated and returned by the '_get_pipelines' function.
Your Environment
Include as many relevant details about the environment in which you experienced the bug:
- Kedro version used (
pip show kedroorkedro -V): kedro, version 0.17.0 - Python version used (
python -V): Python 3.7.9 - Operating system and version: MacOS Catanina Version 10.15.4
- Environment: virtual environment used to run the program
- Error status: happens when running the Flask Application
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)

Top Related StackOverflow Question
Hi @MerelTheisenQB,
Thank you for your feedback, the code that I was not pointing to the correct path of the project, so the step by step debugging (as you suggested) helped me find the issue. So my final code is below:
Have a great week!
It’s built by kedro, you can use it by importing it like this
from kedro.framework.startup import _add_src_to_path🙂