在虚拟机(Linux Ubuntu 22.10、Python 3.10.7)上安装 pip 后,运行
jupyter
会出现错误jupyter notebook
我已经尝试过做
File "/home/username/.local/bin/jupyter-notebook", line 5, in <module>
from notebook.app import main
File "/home/username/.local/lib/python3.10/site-packages/notebook/app.py", line 17, in <module>
from jupyter_server.serverapp import flags
File "/home/username/.local/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 114, in <module>
from jupyter_server.services.contents.filemanager import (
File "/home/username/.local/lib/python3.10/site-packages/jupyter_server/services/contents/filemanager.py", line 23, in <module>
from anyio.to_thread import run_sync
File "/home/username/.local/lib/python3.10/site-packages/anyio/__init__.py", line 27, in <module>
from ._core._sockets import connect_tcp as connect_tcp
File "/home/username/.local/lib/python3.10/site-packages/anyio/_core/_sockets.py", line 35, in <module>
from exceptiongroup import ExceptionGroup
File "/home/username/.local/lib/python3.10/site-packages/exceptiongroup/__init__.py", line 20, in <module>
from ._formatting import (
File "/home/username/.local/lib/python3.10/site-packages/exceptiongroup/_formatting.py", line 394, in <module>
assert sys.excepthook is apport_python_hook.apport_excepthook
AssertionError
如here
我怀疑这与 Jupyter 对 IPython 的依赖有关,因为当我尝试运行“ipython --pylab”时,我得到了完全相同的错误。
我找到的唯一“解决方案”是进入“_formatting.py”文件并注释掉第 394 行的“assert sys.excepthook is apport_python_hook.apport_excepthook”。保存后,我可以启动交互式 shell在 IPython 中,我可以运行 Jupyter。
我想强调,这不太理想,我强烈建议不要这样做,但它可能会帮助您/其他人排除故障。