This document contains fixes for Qt/PySide6 import errors and missing system libraries when running pyqtgraph applications on Ubuntu.
If you're encountering Qt/PySide6 import errors, follow these steps:
-
Install system libraries (run as root/admin):
bash fix_qt_dependencies.sh # or ./fix_qt_dependencies.sh -
If you still get PySide6 version attribute errors, patch pyqtgraph:
python patch_pyqtgraph.py # or bash patch_pyqtgraph.sh
That's it! Your application should now work. See below for detailed explanations of each fix.
When running Python applications that use pyqtgraph and PySide6, you may encounter various import errors related to missing system libraries.
Run the following command to install all required Qt/X11 dependencies:
apt-get update && apt-get install -y \
libfontconfig1 \
libxkbcommon0 \
libxkbcommon-x11-0 \
libxcb1 \
libxcb-xinerama0 \
libxcb-xfixes0 \
libxcb-xinput0 \
libxcb-xkb1 \
libxcb-randr0 \
libxcb-shape0 \
libxcb-render0 \
libxcb-render-util0 \
libxcb-image0 \
libxcb-icccm4 \
libxcb-sync1 \
libxcb-keysyms1 \
libxcb-xtest0 \
libxcb-shm0 \
libxcb-util1 \
libxcb-dri3-0 \
libxcb-present0 \
libx11-xcb1 \
libxrender1 \
libxi6 \
libxfixes3 \
libxcb-cursor0 \
libdbus-1-3 \
dbusError:
ImportError: libfontconfig.so.1: cannot open shared object file: No such file or directory
Fix:
apt-get install -y libfontconfig1Error:
ImportError: libxkbcommon.so.0: cannot open shared object file: No such file or directory
Fix:
apt-get install -y libxkbcommon0 libxkbcommon-x11-0Error:
ImportError: libdbus-1.so.3: cannot open shared object file: No such file or directory
Fix:
apt-get install -y libdbus-1-3 dbusError:
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb"
Fix:
apt-get install -y libxcb-cursor0Error:
AttributeError: module 'PySide6' has no attribute '__version__'
Location: pyqtgraph/Qt/__init__.py line 251
Fix: Find the line:
VERSION_INFO = 'PySide6 ' + PySide6.__version__ + ' Qt ' + QtCore.__version__Replace with:
pyside6_version = getattr(PySide6, '__version__', QtCore.__version__)
VERSION_INFO = 'PySide6 ' + pyside6_version + ' Qt ' + QtCore.__version__File path (adjust for your Python environment):
# Find your pyqtgraph installation:
python -c "import pyqtgraph; print(pyqtgraph.__file__)"
# Then edit: <path>/pyqtgraph/Qt/__init__.pyError:
ImportError: cannot import name '__version_info__' from 'PySide6'
Location: pyqtgraph/Qt/internals.py line 18
Fix: Find the section:
elif QT_LIB == 'PySide6':
from PySide6 import __version_info__ as pyside_version_info
qt_version_info = QtCore.__version_info__Replace with:
elif QT_LIB == 'PySide6':
try:
from PySide6 import __version_info__ as pyside_version_info
except (ImportError, AttributeError):
# PySide6 doesn't always have __version_info__, use QtCore's instead
pyside_version_info = QtCore.__version_info__
qt_version_info = QtCore.__version_info__File path (adjust for your Python environment):
# Find your pyqtgraph installation:
python -c "import pyqtgraph; print(pyqtgraph.__file__)"
# Then edit: <path>/pyqtgraph/Qt/internals.pyUse the provided script to install all required libraries:
bash fix_qt_dependencies.shOr run it directly:
./fix_qt_dependencies.shAfter installing libraries, if you still get PySide6 version attribute errors, patch pyqtgraph:
Using Python script (recommended):
python patch_pyqtgraph.pyOr if using a specific Python:
python patch_pyqtgraph.py python3Using bash script:
bash patch_pyqtgraph.shIf you prefer to install manually, run:
apt-get update && apt-get install -y \
libfontconfig1 \
libxkbcommon0 \
libxkbcommon-x11-0 \
libxcb1 \
libxcb-xinerama0 \
libxcb-xfixes0 \
libxcb-xinput0 \
libxcb-xkb1 \
libxcb-randr0 \
libxcb-shape0 \
libxcb-render0 \
libxcb-render-util0 \
libxcb-image0 \
libxcb-icccm4 \
libxcb-sync1 \
libxcb-keysyms1 \
libxcb-xtest0 \
libxcb-shm0 \
libxcb-util1 \
libxcb-dri3-0 \
libxcb-present0 \
libx11-xcb1 \
libxrender1 \
libxi6 \
libxfixes3 \
libxcb-cursor0 \
libdbus-1-3 \
dbusAfter installing libraries, verify they're available:
# Check for fontconfig
ldconfig -p | grep fontconfig
# Check for xkbcommon
ldconfig -p | grep xkbcommon
# Check for dbus
ldconfig -p | grep dbus
# Check for xcb-cursor
ldconfig -p | grep xcb-cursor- OS: Ubuntu 22.04 (Jammy)
- Python: 3.11
- Qt: PySide6 6.10.1
- Library: pyqtgraph
-
If you're on a headless server without a display, you may need to:
- Use X11 forwarding if connecting via SSH
- Use a virtual display with
xvfb-run - Use the
offscreenQt platform plugin - Or modify the application to work headless
-
The pyqtgraph patches are temporary workarounds for compatibility issues between pyqtgraph and certain PySide6 installations. These may be fixed in future versions of pyqtgraph.
Created: