Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server_extensions is deprecated, use nbserver_extensions #591

Closed
ELLIOTTCABLE opened this issue Apr 25, 2016 · 8 comments
Closed

server_extensions is deprecated, use nbserver_extensions #591

ELLIOTTCABLE opened this issue Apr 25, 2016 · 8 comments

Comments

@ELLIOTTCABLE
Copy link

With the latest IPy-nb-ex, I'm getting this on boot:

[W 19:23:08.611 NotebookApp] server_extensions is deprecated, use nbserver_extensions
/usr/local/lib/python2.7/site-packages/widgetsnbextension/__init__.py:30: UserWarning: To use the jupyter-js-widgets nbextension, you'll need to update
    the Jupyter notebook to version 4.2 or later.
  the Jupyter notebook to version 4.2 or later.""")

Jupyter is fully updated, so what is this asking me to do?

@jcb91
Copy link
Member

jcb91 commented Apr 25, 2016

There are two separate issues here:

The second warning is nothing to do with this repo, but comes from the ipywidgets package. From a cursory inspection of their widgetsnbextension/widgetsnbextension/__init__.py#L29-L30 and notebook's notebook/notebookapp.py#L242, it seems to be a warning that fires regardless of the actually installed jupyter notebook version - it might be worth opening an issue with ipywidgets to make it conditional on a relevant notebook version.

The first is from this repo, and it's a result of one of your jupyter config files containing the key server_extensions, which has been deprecated. This key is used to tell jupyter which server extensions to load, in the case of this repo, the nbextensions.py server extension, which provides the configuration page at the <base_url>/nbextensions url. The install script for this repo alters the config key to ensure that that extension gets loaded. Since #581, the install script uses the appropriate new config key, which is nbserver_extensions, as noted in the error message. However, it won't remove any previous server_extensions key remaining from a previous install (perhaps it should?). To migrate settings from the old key to the new key, you should be able to use the following python snippet:

from jupyter_core.paths import jupyter_config_path
from traitlets.config.manager import BaseJSONConfigManager

config_basename, section_name = 'jupyter_notebook_config', 'NotebookApp'
old_key, new_key = 'server_extensions', 'nbserver_extensions'
for config_dir in jupyter_config_path():
    cm = BaseJSONConfigManager(config_dir=config_dir)
    config = cm.get(config_basename)
    section = config.get(section_name, {})
    if old_key not in section:
        continue
    print('in {}'.format(cm.file_name(config_basename)))
    print('- migrating keys from {} to {}'.format(old_key, new_key))
    for servext in section[old_key]:
        print('-   moving extension {}'.format(servext))
        section.setdefault(new_key, {})[servext] = True
    print('- removing key {}.{}'.format(section_name, old_key))
    section[old_key] = None
    print('')
    cm.update(config_basename, config)

Hope that helps...

@den-run-ai
Copy link

@jcb91 I tried your script and still getting the same error:

from jupyter_core.paths import jupyter_config_path
from traitlets.config.manager import BaseJSONConfigManager

config_basename, section_name = 'jupyter_notebook_config', 'NotebookApp'
old_key, new_key = 'server_extensions', 'nbserver_extensions'
for config_dir in jupyter_config_path():
    cm = BaseJSONConfigManager(config_dir=config_dir)
    config = cm.get(config_basename)
    section = config.get(section_name, {})
    if old_key not in section:
        continue
    print('in {}'.format(cm.file_name(config_basename)))
    print('- migrating keys from {} to {}'.format(old_key, new_key))
    for servext in section[old_key]:
        print('-   moving extension {}'.format(servext))
        section.setdefault(new_key, {})[servext] = True
    print('- removing key {}.{}'.format(section_name, old_key))
    section[old_key] = None
    print('')
    cm.update(config_basename, config)
in C:\Users\denis.akhiyarov\.jupyter\jupyter_notebook_config.json
- migrating keys from server_extensions to nbserver_extensions
-   moving extension nbextensions
- removing key NotebookApp.server_extensions
C:\Users\denis.akhiyarov>jupyter notebook
c:\python\python27_32b\lib\site-packages\widgetsnbextension\__init__.py:30: User
Warning: To use the jupyter-js-widgets nbextension, you'll need to update
    the Jupyter notebook to version 4.2 or later.
  the Jupyter notebook to version 4.2 or later.""")
[W 17:09:01.763 NotebookApp] Error loading server extension nbextensions
    Traceback (most recent call last):
      File "c:\python\python27_32b\lib\site-packages\notebook\notebookapp.py", l
ine 1042, in init_server_extensions
        mod = importlib.import_module(modulename)
      File "c:\python\python27_32b\lib\importlib\__init__.py", line 37, in impor
t_module
        __import__(name)
      File "C:\Users\denis.akhiyarov\AppData\Roaming\jupyter\extensions\nbextens
ions.py", line 8, in <module>
        from notebook.nbextensions import _get_nbext_dir as get_nbext_dir
    ImportError: cannot import name _get_nbext_dir

@den-run-ai
Copy link

ok, after updates, only warning is received:

C:\Users\denis.akhiyarov>pip install -U https://github.com/ipython-contrib/IPyth
on-notebook-extensions/archive/master.zip
Collecting https://github.com/ipython-contrib/IPython-notebook-extensions/archiv
e/master.zip
  Downloading https://github.com/ipython-contrib/IPython-notebook-extensions/arc
hive/master.zip (9.5MB)
    100% |################################| 9.5MB 97kB/s
Requirement already up-to-date: ipython>=4 in c:\python\python27_32b\lib\site-pa
ckages (from Python-contrib-nbextensions===alpha)
Requirement already up-to-date: jupyter in c:\python\python27_32b\lib\site-packa
ges (from Python-contrib-nbextensions===alpha)
Collecting psutil>=2.2.1 (from Python-contrib-nbextensions===alpha)
  Downloading psutil-4.1.0-cp27-cp27m-win32.whl (159kB)
    100% |################################| 163kB 882kB/s
Requirement already up-to-date: pyyaml in c:\python\python27_32b\lib\site-packag
es (from Python-contrib-nbextensions===alpha)
Requirement already up-to-date: traitlets in c:\python\python27_32b\lib\site-pac
kages (from ipython>=4->Python-contrib-nbextensions===alpha)
Requirement already up-to-date: pickleshare in c:\python\python27_32b\lib\site-p
ackages (from ipython>=4->Python-contrib-nbextensions===alpha)
Requirement already up-to-date: simplegeneric>0.8 in c:\python\python27_32b\lib\
site-packages (from ipython>=4->Python-contrib-nbextensions===alpha)
Requirement already up-to-date: backports.shutil-get-terminal-size in c:\python\
python27_32b\lib\site-packages (from ipython>=4->Python-contrib-nbextensions===a
lpha)
Requirement already up-to-date: decorator in c:\python\python27_32b\lib\site-pac
kages (from ipython>=4->Python-contrib-nbextensions===alpha)
Requirement already up-to-date: setuptools>=18.5 in c:\python\python27_32b\lib\s
ite-packages\setuptools-21.0.0-py2.7.egg (from ipython>=4->Python-contrib-nbexte
nsions===alpha)
Requirement already up-to-date: pathlib2 in c:\python\python27_32b\lib\site-pack
ages (from pickleshare->ipython>=4->Python-contrib-nbextensions===alpha)
Requirement already up-to-date: six in c:\python\python27_32b\lib\site-packages
(from pathlib2->pickleshare->ipython>=4->Python-contrib-nbextensions===alpha)
Installing collected packages: psutil, Python-contrib-nbextensions
  Found existing installation: psutil 3.4.2
    Uninstalling psutil-3.4.2:
      Successfully uninstalled psutil-3.4.2
  Found existing installation: Python-contrib-nbextensions alpha
    Uninstalling Python-contrib-nbextensions-alpha:
      Successfully uninstalled Python-contrib-nbextensions-alpha
  Running setup.py install for Python-contrib-nbextensions ... done
Successfully installed Python-contrib-nbextensions-alpha psutil-4.1.0

C:\Users\denis.akhiyarov>jupyter notebook
c:\python\python27_32b\lib\site-packages\widgetsnbextension\__init__.py:30: User
Warning: To use the jupyter-js-widgets nbextension, you'll need to update
    the Jupyter notebook to version 4.2 or later.
  the Jupyter notebook to version 4.2 or later.""")

@jcb91
Copy link
Member

jcb91 commented May 4, 2016

yep, so you were in fact getting another, different, error:

ImportError: cannot import name _get_nbext_dir

but that's been fixed by a combination of #567 and #574 anyway, so your update covered that.

As I mentioned in my first comment in this thread, the

warning is nothing to do with this repo

so, by all means, take it up at ipython/ipywidgets, but I'm afraid there isn't much we can do about it here.

@den-run-ai
Copy link

@jcb91 as you can see above I linked the issue in ipywidgets and got reply from @jdfreder

jupyter-widgets/ipywidgets#558

@jcb91
Copy link
Member

jcb91 commented May 4, 2016

Haha! ok, I'll reply there 😆

@jcb91
Copy link
Member

jcb91 commented May 4, 2016

Also, I should mention that this might be slightly confusing, because there are two files named nbextensions.py. One is part of jupyter notebook, as mentioned in jupyter-widgets/ipywidgets#558. The other is part of this repo (at extensions/nbextensions.py), which provides a jupyter server extension which renders a page for easy control of settings for nbextensions.

@ELLIOTTCABLE
Copy link
Author

Unfortunately, I've lost access to the machine-instance where I was experiencing this … I'm closing it, but leaving it for a maintainer to re-open if somebody else can reproduce, to continue working on a fix. /=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants