Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ImportError: cannot import name 'AsyncKernelManager' from 'jupyter_client` #486

Closed
jonah-juul opened this issue Apr 2, 2020 · 7 comments

Comments

@jonah-juul
Copy link

jonah-juul commented Apr 2, 2020

Error recently appeared past 48 hours. Wondering if anyone has run into this before and knows what root cause could be. Occurs right after pm.execute_notebook.

Using Docker container FROM jupyter/scipy-notebook:latest

Executing:   0%|                                                                                                                                                         | 0/8 [00:00<?, ?cell/s]
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'kernel_manager_class'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/lib/python3.7/site-packages/papermill/execute.py", line 104, in execute_notebook
    **engine_kwargs
  File "/opt/conda/lib/python3.7/site-packages/papermill/engines.py", line 49, in execute_notebook_with_engine
    return self.get_engine(engine_name).execute_notebook(nb, kernel_name, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/papermill/engines.py", line 343, in execute_notebook
    cls.execute_managed_notebook(nb_man, kernel_name, log_output=log_output, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/papermill/engines.py", line 402, in execute_managed_notebook
    return PapermillNotebookClient(nb_man, **final_kwargs).execute()
  File "/opt/conda/lib/python3.7/site-packages/papermill/clientwrap.py", line 36, in execute
    with self.setup_kernel(**kwargs):
  File "/opt/conda/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/opt/conda/lib/python3.7/site-packages/nbclient/client.py", line 401, in setup_kernel
    self.start_kernel_manager()
  File "/opt/conda/lib/python3.7/site-packages/nbclient/client.py", line 328, in start_kernel_manager
    self.km = self.kernel_manager_class(kernel_name=self.kernel_name, config=self.config)
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/opt/conda/lib/python3.7/site-packages/nbclient/client.py", line 240, in _kernel_manager_class_default
    from jupyter_client import AsyncKernelManager
ImportError: cannot import name 'AsyncKernelManager' from 'jupyter_client' (/opt/conda/lib/python3.7/site-packages/jupyter_client/__init__.py)
@jonah-juul
Copy link
Author

Found error - update to jupyter-client, pegging it to jupyter-client==6.1.2 fixes

@MSeal
Copy link
Member

MSeal commented Apr 2, 2020

Yes the dependency chain is a little tighter for the most recent updates on upstream tools. >=6.1.2 should be sufficient and stable now

@mansiparashar
Copy link

Hey, updating isn't fixing the error either

@MSeal
Copy link
Member

MSeal commented Jun 17, 2020

Check your jupyter package versions, and make sure you're running in the environment you think you are.

python -c "from jupyter_client import AsyncKernelManager" is a test for if this issue should be occurring.

@ttpro1995
Copy link

Update jupyter-client work for me

pip install -U jupyter-client

ajbozarth added a commit to ajbozarth/papermill that referenced this issue Aug 13, 2020
As previously raised in nteract#486 nteract#492 nteract#500 nteract#522 and nteract#523 if papermill is
used in an environment with an older version of `jupyter_client` it will
throw an error. This is caused by the dependency `nbclient>=0.2.0`
that depends on `jupyter_client>=6.1.0`. This dependency is overridden
by papermill by having `jupyter_client` in `requirements.txt` without a
version, meaning any version (even an older one) is accepted if already
installed. To make sure the expected version of `jupyter_client` is
installed we should set `jupyter_client>=6.1.0` to match `nbclient`.
MSeal pushed a commit that referenced this issue Aug 17, 2020
As previously raised in #486 #492 #500 #522 and #523 if papermill is
used in an environment with an older version of `jupyter_client` it will
throw an error. This is caused by the dependency `nbclient>=0.2.0`
that depends on `jupyter_client>=6.1.0`. This dependency is overridden
by papermill by having `jupyter_client` in `requirements.txt` without a
version, meaning any version (even an older one) is accepted if already
installed. To make sure the expected version of `jupyter_client` is
installed we should set `jupyter_client>=6.1.0` to match `nbclient`.
@onepunchmate
Copy link

Found error - update to jupyter-client, pegging it to jupyter-client==6.1.2

Hey, I just encountered a similar problem. do you mind elaborate on this part coz I am quite new to python... I have no idea how to do the pegging step.

@ManPython
Copy link

ManPython commented Jul 2, 2021

Found error - update to jupyter-client, pegging it to jupyter-client==6.1.2

Hey, I just encountered a similar problem. do you mind elaborate on this part coz I am quite new to python... I have no idea how to do the pegging step.

Get this as pip install jupyter-client==6.1.2 but take note around some possible conflict.

Requirement already satisfied: ipython-genutils in .p37/lib/python3.7/site-packages (from traitlets->jupyter-client==6.1.2) (0.2.0)
Installing collected packages: jupyter-client
  Attempting uninstall: jupyter-client
    Found existing installation: jupyter-client 6.1.12
    Uninstalling jupyter-client-6.1.12:
      Successfully uninstalled jupyter-client-6.1.12
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
nbclient 0.5.3 requires jupyter-client>=6.1.5, but you have jupyter-client 6.1.2 which is incompatible.
Successfully installed jupyter-client-6.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants