Import Error when installing python3 kernel for Jupyter Notebook

Viewed 269

My python3 kernel for jupyter notebook was not starting, so I uninstalled it. I then ran these commands to create a new python3 kernel.

python3 -m pip install ipykernel
python3 -m ipykernel install --user

However, I get an error when running python3 -m ipykernel install --user.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/ipykernel/__init__.py", line 2, in <module>
    from .connect import *
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/ipykernel/connect.py", line 11, in <module>
    from IPython.core.profiledir import ProfileDir
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/__init__.py", line 56, in <module>
    from .terminal.embed import embed
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/terminal/interactiveshell.py", line 19, in <module>
    from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
    from .application import Application
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/application/__init__.py", line 1, in <module>
    from .application import Application
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/application/application.py", line 42, in <module>
    from prompt_toolkit.buffer import Buffer
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/buffer.py", line 33, in <module>
    from .auto_suggest import AutoSuggest, Suggestion
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/auto_suggest.py", line 19, in <module>
    from .document import Document
  File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/document.py", line 8, in <module>
    from typing import (
ImportError: cannot import name 'NoReturn'

This is the same error I was getting with the original python3 kernel before I removed it. How can I solve this issue?

2 Answers

I solved this issue by uninstalling and reinstalling Anaconda.

It seems, like it's problem with python version, Typing.NoReturn is new for python 3.6.2. Try to install prompt-toolkit with a lower version, for instance 2.0.10. It worked for me:

python3 -m pip install prompt-toolkit==2.0.10

Then try again:

python3 -m ipykernel install --user
Related