Docker笔记本和安装扩展-不使用jupyter基本映像

时间:2019-08-16 12:40:56

标签: jupyter-notebook

我有一个Jupyter Notebook扩展程序...实际上,我有一些...。这是针对我的需求的。

在基于Jupyter映像构建Docker笔记本时,所有扩展都可以很好地安装-我使用以下方法:

    # Pulls just the code for the code to the named branch/tag
    RUN git clone -q -b 'v0.4.0' --single-branch --depth 1 \
https://gitlab+deploy-token-3:abc@gitlab.example.com/my/notebook_extensions

    RUN pip install -q -e /srv/notebook_extensions/lab-toggle \
        && jupyter nbextension install --py lab-toggle \
        && jupyter nbextension enable lab-toggle --py

但是我现在是从非jupyter映像(https://github.com/radiant-rstats/docker的分支)构建的,因此失败了:

 ---> 8eac9cdc2cee
Step 17/19 : RUN jupyter nbextension install /srv/notebook_extensions/tree-page-graphics
 ---> Running in cbf9575ebf22
Making directory: /usr/local/share/jupyter/nbextensions/tree-page-graphics/
Copying: /srv/notebook_extensions/tree-page-graphics/package.json -> /usr/local/share/jupyter/nbextensions/tree-page-graphics/package.json
Copying: /srv/notebook_extensions/tree-page-graphics/README.md -> /usr/local/share/jupyter/nbextensions/tree-page-graphics/README.md
Copying: /srv/notebook_extensions/tree-page-graphics/MANIFEST.in -> /usr/local/share/jupyter/nbextensions/tree-page-graphics/MANIFEST.in
Copying: /srv/notebook_extensions/tree-page-graphics/setup.py -> /usr/local/share/jupyter/nbextensions/tree-page-graphics/setup.py
Copying: /srv/notebook_extensions/tree-page-graphics/.jshintrc -> /usr/local/share/jupyter/nbextensions/tree-page-graphics/.jshintrc
Copying: /srv/notebook_extensions/tree-page-graphics/.gitignore -> /usr/local/share/jupyter/nbextensions/tree-page-graphics/.gitignore
Making directory: /usr/local/share/jupyter/nbextensions/tree-page-graphics/tree-page-graphics
Copying: /srv/notebook_extensions/tree-page-graphics/tree-page-graphics/__init__.py -> /usr/local/share/jupyter/nbextensions/tree-page-graphics/tree-page-graphics/__init__.py
Making directory: /usr/local/share/jupyter/nbextensions/tree-page-graphics/tree-page-graphics/amd
Copying: /srv/notebook_extensions/tree-page-graphics/tree-page-graphics/amd/index.js -> /usr/local/share/jupyter/nbextensions/tree-page-graphics/tree-page-graphics/amd/index.js

    To initialize this nbextension in the browser every time the notebook (or other app) loads:

          jupyter nbextension enable <the entry point>

Removing intermediate container cbf9575ebf22
 ---> 1c99bfcabf18
Step 18/19 : RUN jupyter nbextension enable tree-page-graphics --py
 ---> Running in 5d7808cf317a
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-nbextension", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/usr/local/lib/python3.6/dist-packages/notebook/nbextensions.py", line 988, in start
    super(NBExtensionApp, self).start()
  File "/usr/local/lib/python3.6/dist-packages/jupyter_core/application.py", line 256, in start
    self.subapp.start()
  File "/usr/local/lib/python3.6/dist-packages/notebook/nbextensions.py", line 896, in start
    self.toggle_nbextension_python(self.extra_args[0])
  File "/usr/local/lib/python3.6/dist-packages/notebook/nbextensions.py", line 872, in toggle_nbextension_python
    logger=self.log)
  File "/usr/local/lib/python3.6/dist-packages/notebook/nbextensions.py", line 483, in enable_nbextension_python
    logger=logger)
  File "/usr/local/lib/python3.6/dist-packages/notebook/nbextensions.py", line 380, in _set_nbextension_state_python
    m, nbexts = _get_nbextension_metadata(module)
  File "/usr/local/lib/python3.6/dist-packages/notebook/nbextensions.py", line 1125, in _get_nbextension_metadata
    'it is missing the `_jupyter_nbextension_paths()` method.'.format(module))
KeyError: 'The Python module tree-page-graphics is not a valid nbextension, it is missing the `_jupyter_nbextension_paths()` method.'
ERROR: Service 'radiant-notebook-jupyterhub' failed to build: The command '/bin/sh -c jupyter nbextension enable tree-page-graphics --py' returned a non-zero code: 1

我的假设是某个地方的库路径有问题...这是Docker映像认为它在构建时的位置:

docker run -it --rm 1c99bfcabf18 bash                                                                                                                                                                              1 ↵  3187  13:29:34 
root@14282c4f4a43:/srv# echo $PYTHONPATH
/usr/local/share/jupyter/nbextensions
root@14282c4f4a43:/srv# find / -name tree-page-graphics 2>/dev/null
/usr/local/share/jupyter/nbextensions/tree-page-graphics
/usr/local/share/jupyter/nbextensions/tree-page-graphics/tree-page-graphics
/srv/notebook_extensions/tree-page-graphics
/srv/notebook_extensions/tree-page-graphics/tree-page-graphics
root@14282c4f4a43:/srv# 

如果我稍稍更改启用线,则会收到另一个错误:

root@14282c4f4a43:/srv# jupyter nbextension enable tree-page-graphics
Enabling notebook extension tree-page-graphics...
      - Validating: problems found:
        - require?  X tree-page-graphics
root@14282c4f4a43:/srv# 

作为参考,该代码确实具有_jupyter_nbextension_paths()方法:

def _jupyter_nbextension_paths():
    return [{
        'section': 'tree',
        'src': 'amd',
        'dest': 'lab-toggle',
        'require': 'lab-toggle/index'
    }]

对于从这里出发的一些帮助,将不胜感激。...

0 个答案:

没有答案