Jupyter notebook 如何将带有python和js组件的nbextension作为labextension安装

Jupyter notebook 如何将带有python和js组件的nbextension作为labextension安装,jupyter-notebook,jupyter-lab,ipywidgets,Jupyter Notebook,Jupyter Lab,Ipywidgets,我在下面创建了一个nb扩展!。从以下位置运行扩展时,扩展正常工作: jupyter notebook 当我从运行相同的扩展时 jupyter lab 扩展不起作用,给我一个错误: Error displaying widget: model not found 以下是控制台上的错误: Could not instantiate widget (anonymous) @ manager-base.js:273 09:27:26.891 default.js:127 Error: Modul

我在下面创建了一个nb扩展!。从以下位置运行扩展时,扩展正常工作:

jupyter notebook
当我从运行相同的扩展时

jupyter lab
扩展不起作用,给我一个错误:

Error displaying widget: model not found
以下是控制台上的错误:

Could not instantiate widget
(anonymous) @ manager-base.js:273

09:27:26.891 default.js:127 Error: Module test_pp, semver range 1.2.0 is not registered as a widget module
    at WidgetManager.loadClass (manager.js:251)
test_pp是我尝试运行的扩展模块

以下是使扩展在notebok中工作的命令:

python setup.py build
pip install -e .
jupyter nbextension install --py test_pp
jupyter nbextension enable --py test_pp
jupyter notebook
笔记本电脑扩展的文件夹结构:

test_pp
  js
    lib
      embed.js
      extension.js
      index.js
      labplugin.js
      test_pp.js <------ The javascript part of extension
    node_modules
    package.json
    webpack.config.js
  test_pp
    static
    __init__.py
    _version.py
    test_pp.py <-------- The extension server side python
给出了我上面描述的错误。运行命令以查看扩展:

(base) C:\data\OnScale_Jupyter\jupyterlab\test_pp>jupyter labextension list
JupyterLab v1.1.3
Known labextensions:
   app dir: c:\users\anils\miniconda3\share\jupyter\lab
        @jupyter-widgets/jupyterlab-manager v1.0.2 enabled  ok
        test_pp v0.1.0 enabled  ok* <----- why is there a star

   local extensions:
        test_pp: C:\data\OnScale_Jupyter\jupyterlab\test_pp\js
(基本)C:\data\OnScale\u Jupyter\jupyterlab\test\u pp>Jupyter实验室扩展列表
JupyterLab v1.1.3
已知labextensions:
应用程序目录:c:\users\anils\miniconda3\share\jupyter\lab
@jupyter widgets/jupyterlab manager v1.0.2已启用ok

test_pp v0.1.0已启用ok*检查javascript控制台输出。“找不到型号”有时意味着您要求的库的版本号与已安装库的版本号不匹配。请参阅jupyter小部件cookiecutter的此修补程序,例如,它解决了一个类似的问题:
from test_pp import test_pp
pp = test_pp.PostProcessor()
pp.initWidget()
data = 1
pp.set_data(data)
pp
(base) C:\data\OnScale_Jupyter\jupyterlab\test_pp>jupyter labextension list
JupyterLab v1.1.3
Known labextensions:
   app dir: c:\users\anils\miniconda3\share\jupyter\lab
        @jupyter-widgets/jupyterlab-manager v1.0.2 enabled  ok
        test_pp v0.1.0 enabled  ok* <----- why is there a star

   local extensions:
        test_pp: C:\data\OnScale_Jupyter\jupyterlab\test_pp\js
[W 10:22:31.781 LabApp] Failed to fetch package metadata for 'test_pp': <HTTPError 404: 'Not Found'>