Registry / data / hyperspy

hyperspy

JSON →
library2.4.0pypypi✓ verified 85d ago

HyperSpy is an open-source Python library, currently at version 2.4.0, providing a comprehensive framework for the interactive analysis of multidimensional datasets, particularly within scientific domains like electron microscopy. It offers tools for efficient exploration, manipulation, and visualization of complex data arrays, including those larger than available memory. The project maintains an active development pace with several minor releases annually, and significant architectural changes in major versions like 2.0.

pip install hyperspy
INSTALL
IMPORT
SIG · HYPERSPY
H
hyperspy
datapythonv2.4.0
Install
21.9s avg
Import
775ms
Disk
490MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 20.55s
py 3.11
✓ —
✓ 20.5s
py 3.12
✓ —
✓ 20.75s
py 3.13
✓ —
✓ 21.45s
py 3.9
✕ build_error
✓ 26.3s
490MB installed
● package 490MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

hs
import hyperspy.api as hs
The recommended way to import HyperSpy, making all public packages, functions, and classes available via the 'hs' alias.
Signal1D, Signal2D, BaseSignal
from hyperspy.signals import Signal1D
Directly importing specific Signal classes for creating signals from NumPy arrays when not using `hs.load`.

This quickstart demonstrates how to import HyperSpy, load an example dataset, and plot it. It also includes commented-out code to illustrate how to create a signal directly from a NumPy array and set its axes properties, which is useful for custom data.

import hyperspy.api as hs import numpy as np # Load example data (e.g., an EDS spectrum image) s = hs.datasets.example_signals.EDS_TEM_Spectrum() # Or create a signal from a numpy array # data = np.random.rand(10, 10, 1024) # e.g., 10x10 image of 1024-channel spectra # s_from_array = hs.signals.Signal1D(data) # s_from_array.set_axes(axis=0, name='X', units='nm') # s_from_array.set_axes(axis=1, name='Y', units='nm') # s_from_array.set_signal_axis(0, name='Energy', units='eV') print(s) s.plot()
Debug
Known issues
breakingBreaking changes in HyperSpy 2.0+: The library was split into a core package and `RosettaSciIO` for I/O operations. Many domain-specific signal classes (e.g., EELS, EDS, Holography) were moved out of the core library into specialized HyperSpy extensions. Direct imports or functionality relying on these classes within the main `hyperspy` package will fail.
fix
For I/O, ensure `RosettaSciIO` is installed (it's a dependency of `hyperspy`). For domain-specific signals, install the relevant HyperSpy extension package (e.g., `hyperspy-eels`, `hyperspy-eds`). Check the official documentation for specific migration paths.
affects: >=2.0.0
breakingPython 2 support was dropped with HyperSpy 0.8.4. All versions since require Python 3.
fix
Ensure your environment uses Python 3.10 or newer (as per current PyPI requirements). If you must use Python 2, install HyperSpy 0.8.3 or earlier.
affects: >=0.8.4
deprecatedGUI elements based on `traitsui` and `ipywidgets` are no longer included in the core HyperSpy package by default since version 1.3. These functionalities are now provided by separate packages, `hyperspy-gui-ipywidgets` and `hyperspy-gui-traitsui`.
fix
If you rely on interactive GUI elements, explicitly install the necessary GUI package: `pip install hyperspy-gui-ipywidgets` or `pip install hyperspy-gui-traitsui` (or `conda install` equivalent).
affects: >=1.3.0
deprecatedThe direct `hspy` API (e.g., `import hspy`) was deprecated in favor of `hyperspy.api` in version 0.8.4. While older versions might still tolerate it, it's considered an outdated pattern.
fix
Always use `import hyperspy.api as hs` for importing HyperSpy functionalities.
affects: >=0.8.4
gotchaHyperSpy distinguishes between 'navigation' and 'signal' dimensions for multidimensional arrays. Most functions operate on signal axes and iterate on navigation axes. This is a core concept that can be confusing if not understood.
fix
Familiarize yourself with HyperSpy's axis management (e.g., `s.axes_manager`, `s.metadata.axes`). Understand that `s.data` is the underlying NumPy array, but HyperSpy's methods operate on the `Signal` object which handles these distinctions automatically.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'hyperspy.eds'
Specific signal classes and functionalities for domains like EDS (Energy-Dispersive X-ray Spectrometry) were moved out of the core `hyperspy` library in version 2.0.
fix
Install the relevant HyperSpy extension package, e.g., `pip install hyperspy-eds`. Check the HyperSpy documentation for a list of available extensions.
AttributeError: 'BaseSignal' object has no attribute 'gui'
The GUI components for HyperSpy were split into separate packages (`hyperspy-gui-ipywidgets`, `hyperspy-gui-traitsui`) since version 1.3 and are no longer installed by default.
fix
Install the desired GUI package, e.g., `pip install hyperspy-gui-ipywidgets`, then restart your Python environment. Ensure you have the necessary GUI backend installed (e.g., `ipywidgets` for Jupyter Notebooks).
TypeError: 'AxesManager' object is not subscriptable
Direct indexing of Signal objects (e.g., `s[0, 0]`) was deprecated in older versions in favor of `s.isig` and `s.inav` for explicit signal and navigation axis indexing. While some direct indexing might still work for specific cases, misusing it can lead to this error.
fix
Use the explicit indexing methods: `s.isig[...]` for signal dimensions and `s.inav[...]` for navigation dimensions to avoid ambiguity and ensure correct slicing and access.
MemoryError: Unable to allocate array with shape (..., ...) and data type float64
This often occurs when working with very large datasets, especially when performing memory-intensive operations like calculating errors during model fitting, which by default requires large memory.
fix
For fitting, pass `calculate_errors=False` to `multifit()` if errors are not immediately needed, or consider using a nonlinear optimizer in a second pass once parameters are optimized. When possible, use lazy loading or Dask arrays for out-of-core processing of large datasets, which HyperSpy supports implicitly through its `BaseSignal` abstraction. Consider increasing available RAM or processing data in smaller chunks.
Upgrade
Version history
2.4.0latest on PyPI · released Jan 26, 2026
Audit
Dependencies
h5pyoptionalRecommended for full functionality, especially for HDF5-based file formats.
scikit-imageoptionalRecommended for advanced image processing functionalities, such as subpixel alignment and peak finding. Also for blockfile support via RosettaSciIO.
scikit-learnoptionalRecommended for machine learning features.
lxmloptionalRecommended for full functionality, likely related to metadata parsing.
statsmodelsoptionalRequired for the lowess filter since version 0.7.2.
hyperspy-gui-ipywidgetsoptionalProvides Jupyter Notebook GUI elements; split from core HyperSpy in v1.3.
hyperspy-gui-traitsuioptionalProvides TraitsUI-based GUI elements; split from core HyperSpy in v1.3.
Agent activity
4 hits · last 30 days
node
4
Resources
hyperspy — pip install hyperspy · libregistry