【问题标题】:fix the location /nbextensions ressources in Jupyter修复 Jupyter 中的位置 /nbextensions 资源
【发布时间】:2022-04-20 22:45:36
【问题描述】:

我正在尝试在 Ubuntu 14.04 上安装和运行 Jupyter。安装似乎没问题,但是当我打开浏览器并尝试打开 Python 笔记本时,浏览器会弹出一个带有 Connection Failed 标题的窗口:

无法建立到笔记本服务器的连接。笔记本电脑将继续尝试重新连接。检查您的网络连接或笔记本服务器配置。

问题出在服务器端:Jupyter 无法成功定位 nbextensions 资源,如以下警告行所示:

404 GET /nbextensions/widgets/notebook/js/extension.js

这个错误之前已经提出过,但没有建议的解决方案可以为我解决它。 我在 Ubuntu 16.04 上遇到了同样的问题。

这是我的配置:

~$ python -V
Python 3.5.3
~$ pip3 -V
pip 9.0.1 from /opt/python3.5/lib/python3.5/site-packages (python 3.5)
~$ jupyter --version
4.2.1
~$ jupyter notebook --version
4.3.2

这是服务器上的 Jupyter 输出:

~$ jupyter notebook --ip=192.168.2.15 --port=8080 --no-browser
[I 15:46:03.317 NotebookApp] Serving notebooks from local directory: /home/foo
[I 15:46:03.318 NotebookApp] 0 active kernels
[I 15:46:03.318 NotebookApp] The Jupyter Notebook is running at: http://192.168.2.15:8080/?token=9df9879c1ce98a4b9bff1c483110a00d08fa1645ec09bdc8
[I 15:46:03.318 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:46:03.318 NotebookApp]
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://192.168.2.15:8080/?token=9df9879c1ce98a4b9bff1c483110a00d08fa1645ec09bdc8
[I 15:46:22.058 NotebookApp] Creating new notebook in
[W 15:46:22.645 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20170209154602 (161.106.4.5) 10.77ms referer=http://blabla:8080/notebooks/Untitled1.ipynb?kernel_name=python3
[I 15:46:22.749 NotebookApp] Kernel started: c35da40d-1ba0-4680-80f7-b0ab28c3f75c

【问题讨论】:

  • 我在浏览器和服务器之间有代理防火墙时遇到了问题。我发现它在没有代理防火墙的情况下工作正常(代理防火墙可能稍微修改了 HTTP 有效负载)。因此,我安装了一个证书并在 --port=443 上使用 --certfile 和 --keyfile 选项启动了 jupyter notebook 命令,这解决了最初的问题。

标签: python-3.x proxy firewall jupyter-notebook


【解决方案1】:

需要加载nbextensions

安装pip3 install ipywidgets

更改文件:~/.jupyter/nbconfig/notebook.json

{
  "load_extensions": {
    "jupyter-js-widgets/extension": true
  }
}

其他包:

pip3 install jupyter-js-widgets-nbextension
pip3 install nbextensions

重新运行 jupyter Notebook

【讨论】:

  • 这为我解决了这个问题。如果我根本不需要任何扩展,我仍然不明白为什么我需要安装 ipywidgets,以使烦人的 404 错误消失。
【解决方案2】:

我最近在我的 jupyter notebook 上也遇到了这个问题

404 GET /nbextensions/widgets/notebook/js/extension.js

与 python@3.10 从自制软件安装 在带有 m1 的 macos 中。 我不能像zhi.yang建议的那样解决,我不得不这样做

jupyter nbextension install --py widgetsnbextension --user
jupyter nbextension enable --py widgetsnbextension --user
jupyter nbextension install --py ipympl --user
jupyter nbextension enable --py ipympl --user

然后我可以看到它适用于

>jupyter nbextension list 
notebook section
 jupyter-matplotlib/extension  enabled 
 - Validating: OK
 jupyter-js-widgets/extension  enabled 
 - Validating: OK

由于某种原因,如果我安装 python 虚拟环境,安装 jupyter,安装 matplotlib 并安装 ipympl,笔记本中的小部件绘图会自动工作,而无需执行上述操作。当我使用自制软件为我的用户重新安装 python 时,情况并非如此。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-26
    • 2018-06-29
    • 1970-01-01
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    • 2022-01-10
    • 2017-12-04
    相关资源
    最近更新 更多