question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[KED-1454] reload_kedro magic script not working with jupyter

See original GitHub issue

Description

I created a new kedro environment and ran kedro jupyter notebook to create a notebook. Then I execute the %reload_kedro command which gave the following error: 2020-02-22 09:45:31,139 - root - ERROR - Kedro appears not to be installed in your current environment or your current IPython session was not started in a valid Kedro project.

I also executed the kedro ipython command to get the following error: Traceback (most recent call last): File “/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/application/current.py”, line 6, in <module> from contextvars import ContextVar ModuleNotFoundError: No module named ‘contextvars’

Context

How has this bug affected you? What were you trying to accomplish? i am unable to use jupyter notebook with kedro context

Steps to Reproduce

  1. create a new project
  2. create a notebook with kedro jupyter notebook
  3. make some catalog entries
  4. try to run the %reload_kedro magic command

Expected Result

it should load the catalog entries

Actual Result

error

-- If you received an error, place it here.

2020-02-22 09:45:31,139 - root - ERROR - Kedro appears not to be installed in your current environment or your current IPython session was not started in a valid Kedro project.

ImportError Traceback (most recent call last) <ipython-input-10-abfcd54c960b> in <module> ----> 1 get_ipython().run_line_magic(‘reload_kedro’, ‘’)

/anaconda3/envs/python3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth) 2312 kwargs[‘local_ns’] = sys._getframe(stack_depth).f_locals 2313 with self.builtin_trap: -> 2314 result = fn(*args, **kwargs) 2315 return result 2316

~/Desktop/personal/code/DataScience/kaggle_future_sales/future_sales/.ipython/profile_default/startup/00-kedro-init.py in reload_kedro(path, line) 20 try: 21 import kedro.config.default_logger —> 22 from kedro.context import KEDRO_ENV_VAR, load_context 23 from kedro.cli.jupyter import collect_line_magic 24 except ImportError:

ImportError: cannot import name ‘KEDRO_ENV_VAR’ from ‘kedro.context’ (/anaconda3/envs/python3/lib/python3.7/site-packages/kedro/context/init.py)

-------------------------------------------------------------------------------
Starting a Kedro session with the following variables in scope
startup_error, context
Use the line magic %reload_kedro to refresh them
or to see the error message if they are undefined
-------------------------------------------------------------------------------
ipython
Traceback (most recent call last):
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/application/current.py", line 6, in <module>
    from contextvars import ContextVar
ModuleNotFoundError: No module named 'contextvars'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/anaconda3/envs/future_sales/bin/ipython", line 5, in <module>
    from IPython import start_ipython
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/IPython/__init__.py", line 56, in <module>
    from .terminal.embed import embed
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 19, in <module>
    from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
    from .application import Application
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/application/__init__.py", line 1, in <module>
    from .application import Application
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 38, in <module>
    from prompt_toolkit.buffer import Buffer
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/buffer.py", line 28, in <module>
    from .application.current import get_app
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/application/current.py", line 8, in <module>
    from prompt_toolkit.eventloop.dummy_contextvars import ContextVar  # type: ignore
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/eventloop/__init__.py", line 1, in <module>
    from .async_generator import generator_to_async_generator
  File "/anaconda3/envs/future_sales/lib/python3.6/site-packages/prompt_toolkit/eventloop/async_generator.py", line 5, in <module>
    from typing import AsyncGenerator, Callable, Iterable, TypeVar, Union
ImportError: cannot import name 'AsyncGenerator'

Your Environment

Include as many relevant details about the environment in which you experienced the bug: kedro, version 0.15.5

  • Kedro version used (pip show kedro or kedro -V):
  • Python version used (python -V): Python 3.6.0 :: Continuum Analytics, Inc.
  • Operating system and version: macOS 10.14.6

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
martinlarsalbertcommented, Mar 7, 2022

@Francisco-Reveriano This worked for me:

%load_ext kedro.extras.extensions.ipython
%reload_kedro
1reaction
yetudadacommented, May 31, 2020

@mzjp2 Hi thanks! It works like charm, will look at the release note before raising the question next time 🤣 May I ask does quantumblack provide any YouTube/learning channel for Kedro?

@oscartse68 We’re so glad that you’re all sorted out on this one. I have one question and recommendation for you as a follow-up to this question you’ve asked.

My question is, “Why would you like to see a YouTube or video-based learning channel for Kedro?”

And then on that I would definitely recommend checking out the DataEngineerOne series on YouTube. It’s a series of Kedro tutorials on different functionality done by a super user of Kedro.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[KED-1454] reload_kedro magic script not working with ...
Description I created a new kedro environment and ran kedro jupyter notebook to create a notebook. Then I execute the %reload_kedro command ...
Read more >
Use Kedro with IPython and Jupyter Notebooks/Lab
Next, you need to reload Kedro variables by calling %reload_kedro line magic in your Jupyter notebook. Finally, you can save the data by...
Read more >
IPython %run magic -n switch not working
This allows running scripts and reloading the definitions in them without calling code protected by an if __name__ == "__main__" clause. However ...
Read more >
Configuring AWS Glue interactive sessions for Jupyter and ...
Run SQL code. All lines after the initial %%sql magic will be passed as part of the SQL code. Naming sessions. AWS Glue ......
Read more >
PyCharm - Run and debug Jupyter notebook code cells
You can execute the code of the notebook cells in many ways using the icons on the notebook toolbar and cell toolbars, commands...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found