0

I'm trying to use nglview to visualize some pymatgen structures in a jupyter lab notebook.

Simply using import nglview returns the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[51], line 1
----> 1 import nglview
      2 view = nglview.show_pdbid("3pqr")  # load "3pqr" from RCSB PDB and display viewer widget
      3 view

File ~/anaconda3/envs/py38tensorflow/lib/python3.8/site-packages/nglview/__init__.py:4
      1 import warnings
      3 # for doc
----> 4 from . import adaptor, datafiles, show, widget
      5 from ._version import get_versions
      6 from .adaptor import *

File ~/anaconda3/envs/py38tensorflow/lib/python3.8/site-packages/nglview/show.py:13
      3 from . import datafiles
      4 from .adaptor import (ASEStructure, ASETrajectory, BiopythonStructure,
      5                       FileStructure, HTMDTrajectory, IODataStructure,
      6                       IOTBXStructure, MDAnalysisTrajectory, MDTrajTrajectory,
   (...)
     11                       RdkitStructure,
     12                       TextStructure)
---> 13 from .widget import NGLWidget
     15 __all__ = [
     16     'demo',
     17     'show_pdbid',
   (...)
     40     'show_biopython',
     41 ]
     44 def show_pdbid(pdbid, **kwargs):

File ~/anaconda3/envs/py38tensorflow/lib/python3.8/site-packages/nglview/widget.py:19
     15 from traitlets import (Bool, CaselessStrEnum, Dict, Instance, Int, Integer,
     16                        List, Unicode, observe, validate)
     17 import traitlets
---> 19 from . import color, interpolate
     20 from .adaptor import Structure, Trajectory
     21 from .component import ComponentViewer

File ~/anaconda3/envs/py38tensorflow/lib/python3.8/site-packages/nglview/color.py:114
    110         else:
    111             raise ValueError(f"{obj} must be either list of list or string")
--> 114 ColormakerRegistry = _ColormakerRegistry()

File ~/anaconda3/envs/py38tensorflow/lib/python3.8/site-packages/nglview/base.py:10, in _singleton.<locals>.getinstance()
      8 def getinstance():
      9     if cls not in instances:
---> 10         instances[cls] = cls()
     11     return instances[cls]

File ~/anaconda3/envs/py38tensorflow/lib/python3.8/site-packages/nglview/color.py:47, in _ColormakerRegistry.__init__(self, *args, **kwargs)
     45 try:
     46     get_ipython() # only display in notebook
---> 47     self._ipython_display_()
     48 except NameError:
     49     pass

File ~/anaconda3/envs/py38tensorflow/lib/python3.8/site-packages/nglview/color.py:54, in _ColormakerRegistry._ipython_display_(self, **kwargs)
     52 if self._ready:
     53     return
---> 54 super()._ipython_display_(**kwargs)

AttributeError: 'super' object has no attribute '_ipython_display_'

Moreover, I tried installing nglview-js-widgets and got the following but I already have nodejs installed:

Extension Installation Error

An error occurred installing nglview-js-widgets.

Error message:

Please install Node.js and npm before continuing installation. You may be able to install Node.js from your package manager, from conda, or directly from the Node.js website (https://nodejs.org).

R Walser
  • 330
  • 3
  • 16

0 Answers0