dattalab / keypoint-moseq

https://keypoint-moseq.readthedocs.io
Other
68 stars 28 forks source link

ModuleNotFoundError: No module named 'jupyter_bokeh' #51

Closed calebweinreb closed 1 year ago

calebweinreb commented 1 year ago

When running the following cell of the new analysis notebook:

# Install and Enable widget extensions configurator
!jupyter nbextension install --py jupyter_nbextensions_configurator --sys-prefix
!jupyter nbextension enable --py --sys-prefix widgetsnbextension
!jupyter nbextension enable --py --sys-prefix  --py qgrid

# Install bokeh extensions
!jupyter nbextension install --sys-prefix --symlink --py jupyter_bokeh
!jupyter nbextension enable jupyter_bokeh --py --sys-prefix

I get the following error message

Traceback (most recent call last):
  File "/Users/calebweinreb/miniconda3/bin/jupyter-nbextension", line 10, in <module>
    sys.exit(main())
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 269, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 980, in start
    super().start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 258, in start
    self.subapp.start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 708, in start
    self.install_extensions()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 679, in install_extensions
    full_dests = install(self.extra_args[0],
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 203, in install_nbextension_python
    m, nbexts = _get_nbextension_metadata(module)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 1114, in _get_nbextension_metadata
    m = import_item(module)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/traitlets/utils/importstring.py", line 38, in import_item
    return __import__(parts[0])
ModuleNotFoundError: No module named 'jupyter_nbextensions_configurator'
Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: OK
Traceback (most recent call last):
  File "/Users/calebweinreb/miniconda3/bin/jupyter-nbextension", line 10, in <module>
    sys.exit(main())
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 269, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 980, in start
    super().start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 258, in start
    self.subapp.start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 888, in start
    self.toggle_nbextension_python(self.extra_args[0])
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 861, in toggle_nbextension_python
    return toggle(module,
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 474, in enable_nbextension_python
    return _set_nbextension_state_python(True, module, user, sys_prefix,
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 372, in _set_nbextension_state_python
    m, nbexts = _get_nbextension_metadata(module)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 1114, in _get_nbextension_metadata
    m = import_item(module)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/traitlets/utils/importstring.py", line 38, in import_item
    return __import__(parts[0])
ModuleNotFoundError: No module named 'qgrid'
Traceback (most recent call last):
  File "/Users/calebweinreb/miniconda3/bin/jupyter-nbextension", line 10, in <module>
    sys.exit(main())
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 269, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 980, in start
    super().start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 258, in start
    self.subapp.start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 708, in start
    self.install_extensions()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 679, in install_extensions
    full_dests = install(self.extra_args[0],
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 203, in install_nbextension_python
    m, nbexts = _get_nbextension_metadata(module)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 1114, in _get_nbextension_metadata
    m = import_item(module)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/traitlets/utils/importstring.py", line 38, in import_item
    return __import__(parts[0])
ModuleNotFoundError: No module named 'jupyter_bokeh'
Traceback (most recent call last):
  File "/Users/calebweinreb/miniconda3/bin/jupyter-nbextension", line 10, in <module>
    sys.exit(main())
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 269, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 980, in start
    super().start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 258, in start
    self.subapp.start()
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 888, in start
    self.toggle_nbextension_python(self.extra_args[0])
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 861, in toggle_nbextension_python
    return toggle(module,
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 474, in enable_nbextension_python
    return _set_nbextension_state_python(True, module, user, sys_prefix,
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 372, in _set_nbextension_state_python
    m, nbexts = _get_nbextension_metadata(module)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/notebook/nbextensions.py", line 1114, in _get_nbextension_metadata
    m = import_item(module)
  File "/Users/calebweinreb/miniconda3/lib/python3.9/site-packages/traitlets/utils/importstring.py", line 38, in import_item
    return __import__(parts[0])
ModuleNotFoundError: No module named 'jupyter_bokeh'

The module appears to be installed though, e.g. pip list | grep bokeh returns

bokeh                             2.4.3
jupyter-bokeh                     2.0.3

and also I can import jupyter_bokeh without error. I'm not sure whether this affects things downstream though. Bokeh seems to load sucessfully:

Screenshot 2023-05-24 at 9 42 20 AM
versey-sherry commented 1 year ago

Did you install keypoint-moseq with the most updated setup.cfg? I added qgrid and jupyter_bokeh in there

calebweinreb commented 1 year ago

Yes, and both qgrid and jupyter_bokeh are installed and can be imported.

versey-sherry commented 1 year ago

I just did pip install . from the repository but I can't reproduce your error image

calebweinreb commented 1 year ago

Update: I realized the problem is that when running

# Install and Enable widget extensions configurator
!jupyter nbextension install --py jupyter_nbextensions_configurator --sys-prefix
!jupyter nbextension enable --py --sys-prefix widgetsnbextension
!jupyter nbextension enable --py --sys-prefix  --py qgrid

# Install bokeh extensions
!jupyter nbextension install --sys-prefix --symlink --py jupyter_bokeh
!jupyter nbextension enable jupyter_bokeh --py --sys-prefix

a different python was being used. e.g. if I ran ! which python, it showed

/Users/calebweinreb/miniconda3/bin/python

as opposed to

/Users/calebweinreb/miniconda3/envs/keypoint_moseq/bin/python

the reason is because I launched jupyter from my base environment rather than from the keypoint_moseq environment. If I launched the notebook from the keypoint_moseq environment everything works. So I guess the notebook/docs should state clearly that you need to launch it from the right environment.

versey-sherry commented 1 year ago

added to the doc in the notebook: 05fb836b00c3ae025cae36270f14136fe32956b9