silx

raw JSON →
3.0.0 verified Fri May 01 auth: no python

silx is a collection of Python packages to support the development of data assessment, reduction and analysis applications at synchrotron radiation facilities. It provides tools for reading HDF5/NeXus files, histogramming, fitting, 1D/2D visualization, and image processing. Current version is 3.0.0, with releases approximately every 6–12 months.

pip install silx
error ModuleNotFoundError: No module named 'silx.gui'
cause Qt bindings not installed.
fix
Install a Qt binding: pip install silx[gui] or pip install PyQt5.
error ImportError: cannot import name 'fabioh5' from 'silx.io'
cause The module was renamed from fabioh5 to fabio_h5 in silx 1.0.
fix
Change import to: from silx.io import fabio_h5.
error AttributeError: module 'silx' has no attribute 'plot'
cause The top-level silx.plot module was removed in silx 1.0.
fix
Use from silx.gui import plot instead.
error OSError: [Errno 101] Network is unreachable: 'https://...'
cause silx tries to download a test file or load an online resource without internet.
fix
Disable online access or set environment variable SILX_DISABLE_NET=1.
breaking In silx 1.0.0, the old top-level modules (silx.plot, silx.io.fabioh5, silx.math) were reorganized. Code using old import paths will break.
fix Update imports: silx.gui.plot instead of silx.plot; silx.io.fabio_h5 instead of silx.io.fabioh5; silx.math.histogram moved to silx.sx.histogram.
breaking silx 2.0.0 dropped Python 2 support and removed deprecated APIs like silx.math.fit and silx.io.specfile.
fix Use silx.sx.fit or external fitting libraries. Use silx.io.fabio_h5 or h5py directly for SPEC files.
gotcha silx.gui.plot requires a Qt backend. If no Qt bindings are installed (PyQt5, PySide2, etc.), importing silx.gui will raise an ImportError.
fix Install a Qt binding: pip install silx[gui] or pip install PyQt5 (or PySide6).
deprecated Functions in silx.math (like silx.math.histogram) are deprecated in favor of silx.sx functions.
fix Replace calls: silx.math.histogram → silx.sx.histogram.
gotcha silx.io.fabio_h5.open() returns a FabioFrame, not a numpy array. Access the data via .data attribute.
fix Use fr = fabio_h5.open('file'); data = fr.data.

Basic imports and usage of silx: reading files, histogram, and plotting (GUI).

import silx
import numpy as np
from silx import sx
from silx.io import fabio_h5
from silx.gui import plot

# Read a HDF5/NeXus image
import os
filepath = os.environ.get('SILX_TEST_FILE', 'example.h5')
if os.path.exists(filepath):
    data = fabio_h5.open(filepath)
    print(type(data))

# Simple histogram
x = np.random.normal(size=1000)
hist, edges = sx.histogram(x, bins=10)
print('histogram:', hist)

# Create a 1D plot window (GUI only if interactive)
# plot1D = plot.Plot1D()
# plot1D.addCurve(x, y)
# plot1D.show()