问题点
打开jupyter notebook遇到的问题表现:
遇到这个问题,首先需要分析报错信息,不要听信网上一面之词,对解决方法无益处。
[I 11:49:06.081 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
kernel a67705c9-a10f-4e18-9190-03e253b686fd restarted
Traceback (most recent call last):
File "D:\install\HaoZip\py3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\install\HaoZip\py3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\install\HaoZip\py3\lib\site-packages\ipykernel_launcher.py", line 15, in
from ipykernel import kernelapp as app
File "D:\install\HaoZip\py3\lib\site-packages\ipykernel\__init__.py", line 2, in
from .connect import *
File "D:\install\HaoZip\py3\lib\site-packages\ipykernel\connect.py", line 13, in
from IPython.core.profiledir import ProfileDir
File "D:\install\HaoZip\py3\lib\site-packages\IPython\__init__.py", line 55, in
from .terminal.embed import embed
File "D:\install\HaoZip\py3\lib\site-packages\IPython\terminal\embed.py", line 16, in
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "D:\install\HaoZip\py3\lib\site-packages\IPython\terminal\interactiveshell.py", line 20, in
from prompt_toolkit.formatted_text import PygmentsTokens
ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'
问题找到了,接下来对症下药,为什么出现这种情况,首先排除版本的问题
运行如下代码:
conda upgrade notebook
conda upgrade jupyter
结果并没有解决这个问题,继续思考,是不是由于版本的问题,这个时候搜索的问题就有了明确的目的性。最终 的确是由于版本的问题,输入如下代码:
pip3 install --upgrade prompt-toolkit==2.0.4
参考网址: