nipy/niwidgets

Cant import niwidgets

waa8128 opened this issue · 3 comments

import niwidgets

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-c2cf98e8d4d7> in <module>()
----> 1 import niwidgets
      2 #from niwidgets import NiftiWidget

D:\Anaconda3\lib\site-packages\niwidgets\__init__.py in <module>()
      9 # import widget classes.
     10 from .niwidget_volume import NiftiWidget  # noqa
---> 11 from .niwidget_surface import SurfaceWidget  # noqa

D:\Anaconda3\lib\site-packages\niwidgets\niwidget_surface.py in <module>()
      7 from ipywidgets import interact, fixed, IntSlider
      8 # from ipyvolume import gcf
----> 9 import ipyvolume.pylab as p3
     10 import os
     11 # import pathlib & backwards compatibility

D:\Anaconda3\lib\site-packages\ipyvolume\__init__.py in <module>()
      3 
      4 from . import styles
----> 5 from .widgets import *
      6 from .transferfunction import *
      7 from .examples import  *

D:\Anaconda3\lib\site-packages\ipyvolume\widgets.py in <module>()
     10 from .serialize import array_cube_png_serialization, array_serialization, array_sequence_serialization,\
     11     color_serialization, image_serialization, texture_serialization
---> 12 from .transferfunction import *
     13 import warnings
     14 import ipyvolume

D:\Anaconda3\lib\site-packages\ipyvolume\transferfunction.py in <module>()
     11 
     12 import ipyvolume._version
---> 13 semver_range_frontend = "~" + ipyvolume._version.__version_js__
     14 
     15 

AttributeError: module 'ipyvolume' has no attribute '_version'

And i think the question is about jupyter extensions cause that i've tried the code in anaconda prompt and failed:
jupyter nbextension enable --py --sys-prefix ipyvolume

(D:\Anaconda3) C:\Users\Administrator>jupyter nbextension enable --py --sys-prefix ipyvolume
Traceback (most recent call last):
  File "D:\Anaconda3\Scripts\jupyter-nbextension-script.py", line 5, in <module>

    sys.exit(notebook.nbextensions.main())
  File "D:\Anaconda3\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "D:\Anaconda3\lib\site-packages\traitlets\config\application.py", line 653, in launch_instance
    app.start()
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 900, in start
    super(NBExtensionApp, self).start()
  File "D:\Anaconda3\lib\site-packages\jupyter_core\application.py", line 255, in startself.subapp.start()
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 808, in s
tart
    self.toggle_nbextension_python(self.extra_args[0])
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 784, in t
oggle_nbextension_python
    logger=self.log)
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 445, in e
nable_nbextension_python
    logger=logger)
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 360, in _
set_nbextension_state_python
    m, nbexts = _get_nbextension_metadata(module)
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 1034, in
_get_nbextension_metadata
    m = import_item(module)
  File "D:\Anaconda3\lib\site-packages\traitlets\utils\importstring.py", line 42
, in import_item
    return __import__(parts[0])
  File "D:\Anaconda3\lib\site-packages\ipyvolume\__init__.py", line 5, in <modul
e>
    from .widgets import *
  File "D:\Anaconda3\lib\site-packages\ipyvolume\widgets.py", line 12, in <modul
e>
    from .transferfunction import *
  File "D:\Anaconda3\lib\site-packages\ipyvolume\transferfunction.py", line 43,
in <module>
    class TransferFunctionJsBumps(TransferFunction):
TypeError: function() argument 1 must be code, not str

(D:\Anaconda3) C:\Users\Administrator>jupyter nbextension enable --py --sys-pref
ix ipyvolume
Traceback (most recent call last):
  File "D:\Anaconda3\Scripts\jupyter-nbextension-script.py", line 5, in <module>

    sys.exit(notebook.nbextensions.main())
  File "D:\Anaconda3\lib\site-packages\jupyter_core\application.py", line 266, i
n launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "D:\Anaconda3\lib\site-packages\traitlets\config\application.py", line 65
3, in launch_instance
    app.start()
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 900, in s
tart
    super(NBExtensionApp, self).start()
  File "D:\Anaconda3\lib\site-packages\jupyter_core\application.py", line 255, i
n start
    self.subapp.start()
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 808, in s
tart
    self.toggle_nbextension_python(self.extra_args[0])
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 784, in t
oggle_nbextension_python
    logger=self.log)
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 445, in e
nable_nbextension_python
    logger=logger)
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 360, in _
set_nbextension_state_python
    m, nbexts = _get_nbextension_metadata(module)
  File "D:\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 1034, in
_get_nbextension_metadata
    m = import_item(module)
  File "D:\Anaconda3\lib\site-packages\traitlets\utils\importstring.py", line 42
, in import_item
    return __import__(parts[0])
  File "D:\Anaconda3\lib\site-packages\ipyvolume\__init__.py", line 5, in <modul
e>
    from .widgets import *
  File "D:\Anaconda3\lib\site-packages\ipyvolume\widgets.py", line 12, in <modul
e>
    from .transferfunction import *
  File "D:\Anaconda3\lib\site-packages\ipyvolume\transferfunction.py", line 43,
in <module>
    class TransferFunctionJsBumps(TransferFunction):
TypeError: function() argument 1 must be code, not str

(D:\Anaconda3) C:\Users\Administrator>

Apologies for the slow response to this. It seems as if this is an issue with ipyvolume, which I don't have control over. At the moment, I don't have any issues with ipyvolume. Make sure to update to the latest version of that package (pip install -U ipyvolume). If you still have problems, let me know!

Apologies for the slow response to this. It seems as if this is an issue with ipyvolume, which I don't have control over. At the moment, I don't have any issues with ipyvolume. Make sure to update to the latest version of that package (pip install -U ipyvolume). If you still have problems, let me know!

@janfreyberg emmmmmm....I tired to import niwidgets in another computer and met another problem as follow:

import niwidgets

 C:\ProgramData\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-b8cb676be592> in <module>()
----> 1 import niwidgets

C:\ProgramData\Anaconda3\lib\site-packages\niwidgets\__init__.py in <module>()
      8 from .exampledata import exampleatlas, examplezmap, examplet1  # noqa: F401
      9 from .niwidget_volume import NiftiWidget  # noqa: F401
---> 10 from .niwidget_surface import SurfaceWidget  # noqa: F401
     11 from .streamlines import StreamlineWidget  # noqa: F401

C:\ProgramData\Anaconda3\lib\site-packages\niwidgets\niwidget_surface.py in <module>()
      6 from xml.parsers.expat import ExpatError
      7 
----> 8 import ipyvolume.pylab as p3
      9 import matplotlib.pyplot as plt
     10 import nibabel as nb

C:\ProgramData\Anaconda3\lib\site-packages\ipyvolume\__init__.py in <module>()
      3 
      4 from . import styles
----> 5 from .widgets import *
      6 from .transferfunction import *
      7 from . import examples

C:\ProgramData\Anaconda3\lib\site-packages\ipyvolume\widgets.py in <module>()
      8 import logging
      9 import numpy as np
---> 10 from .serialize import array_cube_tile_serialization, array_serialization, array_sequence_serialization,\
     11     color_serialization, image_serialization, texture_serialization
     12 from .transferfunction import *

C:\ProgramData\Anaconda3\lib\site-packages\ipyvolume\serialize.py in <module>()
      7 from . import utils
      8 import ipywidgets
----> 9 import ipywebrtc
     10 import numpy as np
     11 import PIL.Image

C:\ProgramData\Anaconda3\lib\site-packages\ipywebrtc\__init__.py in <module>()
      3 import ipywidgets as widgets
      4 from ._version import version_info, __version__
----> 5 from .webrtc import *
      6 
      7 

C:\ProgramData\Anaconda3\lib\site-packages\ipywebrtc\webrtc.py in <module>()
     11     Undefined
     12 )
---> 13 from ipywidgets import DOMWidget, Image, Video, Audio, register, widget_serialization
     14 from ipython_genutils.py3compat import string_types
     15 import ipywebrtc._version

ImportError: cannot import name 'Video'