我刚刚在 Ubuntu 18.04 上安装了 Jupiter(v 4.4.0)。Python 版本是 3.7。当我尝试运行任何代码时,我都会收到相同的错误消息。我的内核输出如下所示。
I 01:09:32.973 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/daniel/.local/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "/home/daniel/.local/lib/python3.7/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/home/daniel/.local/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/usr/lib/python3/dist-packages/IPython/__init__.py", line 49, in <module>
from .terminal.embed import embed
File "/usr/lib/python3/dist-packages/IPython/terminal/embed.py", line 18, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/usr/lib/python3/dist-packages/IPython/terminal/interactiveshell.py", line 20, in <module>
from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout, create_output
ImportError: cannot import name 'create_prompt_application' from 'prompt_toolkit.shortcuts' (/home/daniel/.local/lib/python3.7/site-packages/prompt_toolkit/shortcuts/__init__.py)
我尝试将 prompt-toolkit 的版本降级到 2.0.1,因为最新版本的 prompt-toolkit 似乎与 IPython 不兼容。降级到 1.0.4 也无济于事。
答案1
通过将 prompt-toolkit 降级至 1.0.15 来解决。