How do I install a Jupyter Notebook Server extension?

1,101 views
Skip to first unread message

Adam Rule

unread,
Feb 24, 2017, 1:10:07 PM2/24/17
to Project Jupyter
I am attempting to follow the directions in the Documentation for writing and installing a custom server extension, but have encountered several issues. How do I install a server extension? And can the documentation be updated?

I copied the example extension code at the end of the documentation to a file called `example_server_handler.py` and put this file into a folder called `server_extension`
  1. When I ran jupyter notebook --NotebookApp.server_extensions="['server_extension.example_server_handler.py']"
    1.  server_extensions is deprecated, use nbserver_extensions
  2. When I ran jupyter notebook --NotebookApp.nbserver_extensions="['server_extension.example_server_handler.py']"
    1. The 'nbserver_extensions' trait of a NotebookApp instance must be a dict, but a value of class 'list' (i.e. ['server_extension.example_server_handler.py']) was specified.
  3. When I ran jupyter notebook --NotebookApp.nbserver_extensions="{'server_extension.example_server_handler.py': True}"
    1. ImportError: No module named 'server_extension'
I assume the issue is that I have not actually installed the extension, or don't have it on my path.

Thomas Kluyver

unread,
Feb 24, 2017, 1:19:02 PM2/24/17
to Project Jupyter
Hi Adam,

Thanks for the heads up, I'll update the docs to use nbserver_extensions.

The module needs to be importable, so server_extension needs to be in one of the directories on sys.path. An easy way to do this is to make it a Python package that can be installed with pip.

Also, it uses the import name of the module, not the filename, so you don't need the .py extension.

Best wishes,
Thomas

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/612089a9-2a1a-4b80-b154-7b6161e45d3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Kluyver

unread,
Feb 24, 2017, 1:27:29 PM2/24/17
to Project Jupyter
On 24 February 2017 at 18:18, Thomas Kluyver <tak...@gmail.com> wrote:
Thanks for the heads up, I'll update the docs to use nbserver_extensions.

Adam Rule

unread,
Feb 24, 2017, 1:49:47 PM2/24/17
to Project Jupyter
Much thanks!
Reply all
Reply to author
Forward
0 new messages