Jupyter 在 Debian 上出现 404 错误,我无法打开任何笔记本

问题描述 投票:0回答:1

我目前无法在运行 Debian 12 的戴尔笔记本电脑上使用 jupyter。我正在 python virtualenv 中运行 jupyter lab。

当我运行

jupyter lab
时,我首先收到以下反复出现的错误消息:

[W 2025-01-15 18:44:52.720 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 39.53ms referer=None

jupyter 菜单在我的 Firefox 浏览器中显示得很好。

然后,当我尝试创建新笔记本时,出现以下 404 错误:

[W 2025-01-15 18:45:03.095 ServerApp] 404 PUT /api/collaboration/session/Untitled.ipynb?1736963103090 ([email protected]) 1.33ms referer=http://localhost:8888/lab

打开的笔记本无法加载: new notebook not loading

这是一些控制台输出:

$ jupyter lab
[I 2025-01-15 18:44:09.733 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2025-01-15 18:44:09.736 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2025-01-15 18:44:09.740 ServerApp] jupyterlab | extension was successfully linked.
[I 2025-01-15 18:44:09.899 ServerApp] notebook_shim | extension was successfully linked.
[I 2025-01-15 18:44:09.909 ServerApp] notebook_shim | extension was successfully loaded.
[I 2025-01-15 18:44:09.910 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2025-01-15 18:44:09.911 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2025-01-15 18:44:09.911 LabApp] JupyterLab extension loaded from /home/noe/Documents/univ/TER/venv/lib/python3.11/site-packages/jupyterlab
[I 2025-01-15 18:44:09.912 LabApp] JupyterLab application directory is /home/noe/Documents/univ/TER/venv/share/jupyter/lab
[I 2025-01-15 18:44:09.912 LabApp] Extension Manager is 'pypi'.
[I 2025-01-15 18:44:09.991 ServerApp] jupyterlab | extension was successfully loaded.
[I 2025-01-15 18:44:09.991 ServerApp] Serving notebooks from local directory: /home/noe/Documents/univ/TER/venv
[I 2025-01-15 18:44:09.991 ServerApp] Jupyter Server 2.15.0 is running at:
[I 2025-01-15 18:44:09.991 ServerApp] http://localhost:8888/lab?token=6b54a68b3230f79b6f719f36cdfd9e3dbafcdcba3bc270e7
[I 2025-01-15 18:44:09.991 ServerApp]     http://127.0.0.1:8888/lab?token=6b54a68b3230f79b6f719f36cdfd9e3dbafcdcba3bc270e7
[I 2025-01-15 18:44:09.991 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2025-01-15 18:44:10.009 ServerApp] 
    
    To access the server, open this file in a browser:
        file:///home/noe/.local/share/jupyter/runtime/jpserver-27699-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/lab?token=6b54a68b3230f79b6f719f36cdfd9e3dbafcdcba3bc270e7
        http://127.0.0.1:8888/lab?token=6b54a68b3230f79b6f719f36cdfd9e3dbafcdcba3bc270e7
[I 2025-01-15 18:44:10.561 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[W 2025-01-15 18:44:12.203 LabApp] Could not determine jupyterlab build status without nodejs
[W 2025-01-15 18:44:52.720 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 39.53ms referer=None
[I 2025-01-15 18:45:03.006 ServerApp] Creating new notebook in 
[W 2025-01-15 18:45:03.095 ServerApp] 404 PUT /api/collaboration/session/Untitled.ipynb?1736963103090 ([email protected]) 1.33ms referer=http://localhost:8888/lab
[W 2025-01-15 18:45:52.743 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 1.03ms referer=None
[W 2025-01-15 18:46:52.756 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 3.77ms referer=None
w[W 2025-01-15 18:47:52.971 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 3.24ms referer=None
[W 2025-01-15 18:48:52.983 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 3.23ms referer=None
[W 2025-01-15 18:49:53.027 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 3.63ms referer=None

Jupyter 版本:

$ jupyter --version
Selected Jupyter core packages...
IPython          : 8.31.0
ipykernel        : 6.29.5
ipywidgets       : not installed
jupyter_client   : 8.6.3
jupyter_core     : 5.7.2
jupyter_server   : 2.15.0
jupyterlab       : 4.3.4
nbclient         : 0.10.2
nbconvert        : 7.16.5
nbformat         : 5.10.4
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.14.3

当我在 virtualenv 之外运行

jupyter-notebook
时,我遇到了同样的错误,并且我仍然无法运行任何笔记本。

我不认为它来自 jupyter 安装,因为我在多次安装中得到了相同的结果。我还能够在 docker 容器中运行 jupyterlab。

python jupyter virtualenv http-status-code-404
1个回答
0
投票

我升级系统后也遇到同样的问题。

就我而言,解决方案是删除 Jupyter 存储在整个系统多个位置的配置和数据。

首先,检查 Jupyter 可能使用哪些路径:

$> venv/bin/jupyter --paths
config:
    ./venv/etc/jupyter
    /home/<USER>/.jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    ./venv/share/jupyter
    /home/<USER>/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /home/<USER>/.local/share/jupyter/runtime

其中一些路径可能不存在,因此您不需要处理它们。其他人可能拥有您打算使用的实际配置和数据(在我的例子中,这是位于

./venv/
的虚拟环境)。

接下来,(重新)移动那些可能包含过时信息的目录,例如,

mv /home/<USER>/.jupyter /home/<USER>/.jupyter.bck # keep as a backup
sudo mv /usr/share/jupyter /usr/share/jupyter.bck

移动配置目录解决了我遇到的一些奇怪但无害的警告。移动数据目录解决了 404 问题并允许我再次打开我的笔记本。

请告诉我这种方法是否适合您;我们可以稍后更新此答案以供以后参考。

© www.soinside.com 2019 - 2024. All rights reserved.