{"id":9973,"library":"napari","title":"Napari","description":"napari is an n-dimensional array viewer in Python, providing an interactive, multi-dimensional data viewer for scientific visualization. It emphasizes image processing and analysis, offering a flexible, plugin-friendly architecture. As of version 0.7.0, it continues active development with regular feature additions and improvements to its core architecture and ecosystem.","status":"active","version":"0.7.0","language":"en","source_language":"en","source_url":"https://github.com/napari/napari","tags":["image processing","scientific visualization","viewer","GUI","n-dimensional data","microscopy"],"install":[{"cmd":"pip install napari[all]","lang":"bash","label":"Recommended (installs PyQt5 backend)"},{"cmd":"pip install napari[pyside6]","lang":"bash","label":"Install with a specific backend (e.g., PySide6)"}],"dependencies":[{"reason":"Core dependency for n-dimensional array data structures used throughout napari.","package":"numpy","optional":false},{"reason":"One of these Qt GUI backends is mandatory for the viewer to function. Installing `napari[all]` will include PyQt5 by default.","package":"PyQt5 / PyQt6 / PySide2 / PySide6","optional":false}],"imports":[{"symbol":"Viewer","correct":"import napari; viewer = napari.Viewer()"},{"note":"`napari.app.run()` was removed in 0.4.17; use `napari.run()` instead.","wrong":"import napari; napari.app.run()","symbol":"run","correct":"import napari; napari.run()"}],"quickstart":{"code":"import napari\nimport numpy as np\n\n# Create an empty napari viewer\nviewer = napari.Viewer()\n\n# Add a 2D image layer with random data\nviewer.add_image(np.random.rand(128, 128), name='random image')\n\n# Start the napari event loop (essential for the GUI to appear and be interactive)\nif __name__ == '__main__':\n    napari.run()","lang":"python","description":"This quickstart initializes a napari viewer, adds a simple 2D image layer generated with NumPy, and ensures the viewer's event loop is started using `napari.run()` for a responsive GUI. Replace `np.random.rand` with your actual image data."},"warnings":[{"fix":"Ensure you have a Qt backend installed: `pip install napari[all]` or `pip install napari[pyside6]` for a specific backend.","message":"Starting with napari 0.7.0, a Qt GUI backend (e.g., PyQt5, PyQt6, PySide2, PySide6) is a mandatory dependency. You must explicitly install one, or use a bundled install like `pip install napari[all]` (which installs PyQt5).","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Instead of `viewer = napari.Viewer(title='My Viewer')`, use `viewer = napari.Viewer(); viewer.window.title = 'My Viewer'`.","message":"The `Viewer` constructor no longer accepts `title` or `ndisplay` arguments directly. These attributes have moved to `viewer.window.title` and `viewer.dims.ndisplay` respectively.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Always include `if __name__ == '__main__': napari.run()` at the end of your script when running napari directly.","message":"The napari viewer will not display or be interactive without starting its event loop. This is typically done with `napari.run()` when the script is executed as the main program.","severity":"gotcha","affected_versions":"all"},{"fix":"Update calls from `napari.app.run()` to `napari.run()`.","message":"The `napari.app.run()` function was removed. Use `napari.run()` instead.","severity":"deprecated","affected_versions":">=0.4.17"},{"fix":"Replace `viewer.add_layer(napari.layers.Image(data))` with `viewer.add_image(data)`.","message":"The Layer API was significantly refactored in version 0.5.0. Direct instantiation of `napari.layers.Image` (and other layer types) for adding to the viewer is discouraged. Instead, use the `viewer.add_image()`, `viewer.add_points()`, etc., methods.","severity":"breaking","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install napari with a backend using `pip install napari[all]` (recommended) or specify a backend like `pip install napari[pyside6]`.","cause":"A required Qt GUI backend (like PyQt5) is not installed alongside napari.","error":"ModuleNotFoundError: No module named 'PyQt5'"},{"fix":"Ensure `napari.run()` is called, typically within an `if __name__ == '__main__':` block, to start and manage the GUI event loop.","cause":"The napari GUI event loop was not started, or closed prematurely, leading to an attempt to interact with a non-existent GUI context.","error":"AttributeError: 'NoneType' object has no attribute 'processEvents'"},{"fix":"Initialize the viewer without `title`/`ndisplay` arguments, then set them as `viewer.window.title = 'My Title'` and `viewer.dims.ndisplay = 3`.","cause":"Attempting to pass `title` (or `ndisplay`) directly to the `napari.Viewer` constructor, which was removed in version 0.6.0.","error":"TypeError: Viewer.__init__() got an unexpected keyword argument 'title'"},{"fix":"Change `napari.app.run()` to `napari.run()`.","cause":"Using the deprecated `napari.app.run()` function from older versions.","error":"DeprecationWarning: napari.app is deprecated and will be removed in a future release."}]}