{"id":21612,"library":"nglview","title":"NGLView","description":"NGLView provides an IPython/Jupyter widget to interactively view molecular structures and trajectories using the NGL Viewer. It supports various file formats (PDB, SDF, MOL2, XYZ, etc.) and integrates with MDTraj, MDAnalysis, and OpenMM. Version 4.0.1 supports Python >=3.7. Development is active on GitHub.","status":"active","version":"4.0.1","language":"python","source_language":"en","source_url":"https://github.com/arose/nglview","tags":["molecular-visualization","jupyter","widget","3d","mdtraj","mdanalysis"],"install":[{"cmd":"pip install nglview","lang":"bash","label":"Basic install"},{"cmd":"pip install nglview[notebook]","lang":"bash","label":"With notebook extension"}],"dependencies":[{"reason":"Core dependency for Jupyter widget.","package":"ipywidgets","optional":false},{"reason":"Required for notebook extension installation.","package":"notebook","optional":true}],"imports":[{"note":"Standard import with alias nv.","wrong":"None","symbol":"nglview","correct":"import nglview as nv"}],"quickstart":{"code":"import nglview as nv\nimport os\n# Use a built-in example (PDB ID 1CRN)\nview = nv.show_pdbid(\"1CRN\")\nview\n# To view a local file:\n# view = nv.show_file(\"protein.pdb\")","lang":"python","description":"Load a molecular structure from a PDB ID or local file and display the interactive 3D viewer in a Jupyter notebook."},"warnings":[{"fix":"For JupyterLab, run: `jupyter labextension install nglview-js-widgets` or use conda.","message":"In JupyterLab, you must install the labextension separately: `jupyter labextension install nglview-js-widgets` or use `conda install -c conda-forge nglview` which includes it.","severity":"gotcha","affected_versions":"all in JupyterLab"},{"fix":"Run: `jupyter nbextension enable nglview --py --sys-prefix`","message":"If the widget does not render, you may need to enable the notebook extension: `jupyter nbextension enable nglview --py --sys-prefix`.","severity":"gotcha","affected_versions":"all"},{"fix":"Update code to use `nglview.NGLWidget` and handle async initialization with `view._init_signals()` if needed.","message":"Version 3.x had breaking changes in the widget API (e.g., `widget.NGLWidget` renamed, asynchronous initialization). Code written for 2.x may not work in 3.x.","severity":"breaking","affected_versions":"3.0+"},{"fix":"Always provide topology via `traj.add_topology()` or pass topology file to `show_mdtraj()` / `show_mdanalysis()`.","message":"Trajectory loading with `add_trajectory()` may fail if the topology file is not provided or mismatched.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"`pip install nglview` or `conda install -c conda-forge nglview`","cause":"NGLView is not installed.","error":"ModuleNotFoundError: No module named 'nglview'"},{"fix":"In JupyterLab: `jupyter labextension install nglview-js-widgets` and restart Jupyter.","cause":"JupyterLab extension not installed or nglview-js-widgets missing.","error":"Error displaying widget: model not found"},{"fix":"Upgrade ipywidgets: `pip install --upgrade ipywidgets` and `jupyter nbextension enable --py widgetsnbextension`.","cause":"Outdated or mismatched ipywidgets version.","error":"Javascript Error: Cannot read property 'on' of undefined"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}