Hi, i’m trying to snap TauonMusicBox and i stumble on an error with lib SDL2 import. On my first try, i got the following error :

RuntimeError: could not find any library for SDL2 (PYSDL2_DLL_PATH: unset)

FTR, i’ve read about this on this post How best to link to SDL2

After reading this post Using git from a program i’ve tried different settings to get the path working with environment key word with no luck, still got an error :

ImportError: could not find any library for SDL2 (PYSDL2_DLL_PATH: :/snap/tauon/x2/usr/lib/x86_64-linux-gnu)

For now, i’m setting PYSDL2_DLL_PATH: $PYSDL2_DLL_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET in environment since that’s where i can see the lib reside in prime directory.

My snap is here and the related issue on original repo is

Does anyone have been experienced with this lib and could give me hints about this ?

the debian package of pysdl2 seems to install its stuff in $PYTHONPATH/dist-packages/sdl2

i’d search for a file thats typically in there like:

find prime/ -name '**'

to find the actual path for the variable …

Thx for answering :slight_smile:

I’ve tried with PYSDL2_DLL_PATH: $PYSDL2_DLL_PATH:$SNAP/lib/python3.6/site-packages/sdl2 which fails too, and with PYTHONPATH: $PYTHONPATH:$SNAP/lib/python3.6/site-packages with no more luck :\

well, did you actually find the file in that path ?

Yes, i can find in prime/usr/lib/x86_64-linux-gnu/.

It seems related to Issue when snap uses python's ctype.util.find_library mentioning a patch here but i can’t figure if this is available for now :\

i literally meant searching for or something equivalent like “” from the above file list.

libSDL2 is irrelevant for the issue you are hitting (it is indeed needed for the backend support but your app is complaining about pysdl2 not about libsdl2 itself)

Sorry but i’m a bit lost, since the error was RuntimeError: could not find any library for SDL2 i was thinking the problem was the lib path.

I’ve tried to follow you advice and setting this PYTHONPATH: $PYTHONPATH:$SNAP/lib/python3.6/site-packages/sdl2 in environment, which led me to a new error :\

Traceback (most recent call last):
  File "/snap/tauon/x8/", line 341, in <module>
    import platform
  File "/snap/tauon/x8/lib/python3.6/site-packages/sdl2/", line 2, in <module>
    from .dll import _bind
ImportError: attempted relative import with no known parent package

Trying to narrow the problem, as said here

Would likely be that the underlying ctypes.util.find_library function is not finding (or accepting) the SDL2 library files.

find_library fails in sdl2/ here

I can go further if i set PYSDL2_DLL_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET in snap yaml + patching pattern here as pattern = "" since the lib files are suffixed by 0 in prime folder => it works

… to be continued

To conclude, there is a bug with ctypes.util.find_library and another bug with pysdl2 that prevent it to correctly load .so* files, i’ve opened an issue for this one