'fix the location /nbextensions ressources in Jupyter

I'm trying to install and run Jupyter on Ubuntu 14.04. The installation seems ok, but when I open a browser and try to open a Python notebook, the browser pops up a window with a Connection Failed title:

A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.

The problem is on the server side: Jupyter does not succeed in locating nbextensions ressources, as indicated by the following warning line:

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

This error has been raised before, but no suggested solution solves it for me. I encounter the same problem on Ubuntu 16.04.

Here is my configuration:

~$ 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

Here is the Jupyter output on the server:

~$ 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


Solution 1:[1]

Need to load nbextensions

Install pip3 install ipywidgets

change file : ~/.jupyter/nbconfig/notebook.json

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

other packages:

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

ReRun the jupyter Notebook

Solution 2:[2]

I also had this problem recently on my jupyter notebook

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

with [email protected] installed from homebrew in a macos with m1. I could not solve as zhi.yang proposed, instead I had to do

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

Then I can see it works with

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

For some reason if I install a python virtual environment, install jupyter, install matplotlib and install ipympl, the widget plots in the notebooks work automatically, without doing the above. This was not the case when I reinstalled python from scratch for my user using homebrew.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zhi.yang
Solution 2 giant_bonsais