PyQt5.QtMultimedia cannot find libpulsecommon-8.0.so

I’m evaluating snap for packaging a PyQt5 application that uses QtMultimedia. I built a snap of the pyqt5 camera example. However, there is an error when I run it.

$ pyqt5camera
Traceback (most recent call last):
  File "camera.py", line 47, in <module>
    from PyQt5.QtMultimedia import (QCamera,
ImportError: libpulsecommon-8.0.so: cannot open shared object file: No such file or directory

My snapcraft.yaml:

name: pyqt5camera
version: git
summary: PyQt5 Camera Demo
description: >
  PyQt5 Camera Demo

confinement: devmode

parts:
  pyqt5camera:
    plugin: python
    python-version: python3
    source: .
    stage-packages:
      - python3-pyqt5.qtmultimedia
      - libpulse0

apps:
  pyqt5camera:
    command: python3 camera.py

I manually looked up the missing so file and found it under examples/multimediawidgets/camera/prime/usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-8.0.so. Since it is in a sub-folder of /usr/lib/x86_64-linux-gnu, would it be the problem?

the pulseaudio subdir is not in your LD_LIBRARY_PATH, you can do something like:

apps:
  pyqt5camera:
    command: python3 camera.py
    environment:
      LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio
    plugs:
      - camera
      ...
4 Likes

I’ve hit this problem too. The libraries in the dir $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio are installed by an official Ubuntu package. @ogra I think requiring the user to manually add the dir to LD_LIBRARY_PATH is pretty ugly. In general, there is plenty of packages that install libraries into subdirectories like this, so this practice is unsustainable on a large scale.

i fully agree that it is annoying, OTOH it also gives the developer full control :wink:

(note that i’m not the one who has implemented it this way, just the one that tries to help around it, filing a bug might help)

there is another option if you find your apps stanza gets to big with LD_LIBRARY_PATH entries for each and every lib in a subdir you can simply make sure the file gets installed under $SNAP/usr/lib:

    organize:
      usr/lib/*/pulseaudio/libpulsecommon-8.0.so: usr/lib/libpulsecommon-8.0.so
2 Likes

Thanks for your help, @ogra.

Rather than listing each subdir of usr/lib/<arch>, what’s most difficult for the user (I think), is simply to figure out what’s wrong with their snap. The snap build OK, but then when it starts, the dynamic linker simply reports that for example libpulsecommon... could not be found, without saying why. The user has to figure out on their own where this library is in the first place and then why it is not found. The snapcraft documentation also does not say anything about the possibility of libraries installed as official Ubuntu packages not being found at runtime.

1 Like