audeering / opensmile-python

Python package for openSMILE
https://audeering.github.io/opensmile-python/
Other
240 stars 32 forks source link

OSError: /path_to_file/libaudresample.so: cannot open shared object file: No such file or directory #79

Open funnyshape opened 1 year ago

funnyshape commented 1 year ago

Hi,

my Issue may or may not be related to #26. When I try to import opensmile, right at the beginning of a python script, this error is thrown:

File "/media/pi1/E04C-9C99/Audio_Pi/SentenceDetect.py", line 11, in import opensmile File "/usr/local/lib/python3.9/dist-packages/opensmile/init.py", line 6, in from opensmile.core.smile import ( File "/usr/local/lib/python3.9/dist-packages/opensmile/core/smile.py", line 10, in import audinterface File "/usr/local/lib/python3.9/dist-packages/audinterface/init.py", line 2, in from audinterface import utils File "/usr/local/lib/python3.9/dist-packages/audinterface/utils/init.py", line 1, in from audinterface.core.utils import ( File "/usr/local/lib/python3.9/dist-packages/audinterface/core/utils.py", line 11, in import audresample File "/home/pi1/audresample/audresample/init.py", line 2, in from audresample.core.api import ( File "/home/pi1/audresample/audresample/core/api.py", line 8, in from audresample.core.lib import lib File "/home/pi1/audresample/audresample/core/lib.py", line 29, in lib = ctypes.cdll.LoadLibrary(lib_path) File "/usr/lib/python3.9/ctypes/init.py", line 452, in LoadLibrary return self._dlltype(name) File "/usr/lib/python3.9/ctypes/init.py", line 374, in init self._handle = _dlopen(self._name, mode) OSError: /home/pi1/audresample/audresample/core/bin/linux/libaudresample.so: cannot open shared object file: No such file or directory

OS: pi os 64 bit python version: 3.9.2 gcc( if needed, looking at issue #33): Debian 10.2.1-6

I already tried to set LD_LIBRARY_PATH, but this did not resolve the issue. Any help would be appreciated!

hagenw commented 1 year ago

The place it tries to load libaudresample.so looks strange to me. Did you install the package to a virtual environment?

For example, if I install audresample to a virtual environment called test with:

$ virtualenv --python=python3.9 test
$ source test/bin/activate
$ pip install audresample

I have the needed file and can also import audresample:

$ ls test/lib/python3.9/site-packages/audresample/core/bin/linux/libaudresample.so
test/lib/python3.9/site-packages/audresample/core/bin/linux/libaudresample.so
$ python -c "import audresample; print(audresample.__version__)"
1.2.1
hagenw commented 1 year ago

It seems like the following code we use inside audresample is not sufficient to find the correct folder in your case:

https://github.com/audeering/audresample/blob/3cd2bff35a2818698316c466a8d84dc6816014c3/audresample/core/lib.py#L8-L14

funnyshape commented 1 year ago

Thank you for your answers. I tried it with and without venv, unfortunately the result is the same.

With ls ... my pi does find the .so file, but I am not even able to import audresample via the import-statement. The Error-Statement is basically the same as above.

Do you think there could be a workaround to find the correct folder?

frankenjoe commented 1 year ago

Do you think there could be a workaround to find the correct folder?

Did you try to copy it manually to: /home/pi1/audresample/audresample/core/bin/linux/libaudresample.so?

funnyshape commented 1 year ago

The file is already there, with permissions set to be executable and viewable by everyone.

frankenjoe commented 1 year ago

The file is already there, with permissions set to be executable and viewable by everyone.

I see, then the problem is not that it cannot find the file, but rather that it cannot load the shared library.

funnyshape commented 1 year ago

Seems so, but I am somewhat lost why this could be the case.

hagenw commented 1 year ago

OS: pi os 64 bit

It seems you are trying to run on a Raspberry Pi, correct? I think it needs arm64 as architecture, but we support only x86-64 at the moment.

funnyshape commented 1 year ago

Yes, I am using a Raspberry Pi. Ah okay, so there is the problem. Do you have, by any chance, the plan to change that in the future?

hagenw commented 1 year ago

Unfortunately, there is no arm64 runner available on Github (https://github.com/actions/runner-images/issues/5631).

There is the option to create a docker image for arm64 and use the docker image to build the binary, e.g. https://github.com/WebAssembly/wabt/pull/2184/files. Or alternatively, we can use an internal runner to build the library. So, yes, it should be possible to add support for it, and we will look into it.

funnyshape commented 1 year ago

Okay, thank you very much!

hagenw commented 1 year ago

Could you maybe use platform (import platform) in Python and report the output of the following two commands from the PI:

funnyshape commented 1 year ago
funnyshape commented 1 year ago

With lscpu I get the following info: Architecture: aarch64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 Vendor ID: ARM Model: 3 Model name: Cortex-A72 Stepping: r0p3

hagenw commented 1 year ago

We build a binary on our RaspberryPi which has:

$ uname -m
armv7l

As a test you could copy it to the audresample/core/bin/linux/ and see if this help fixing the audresample import error. opensmile will then still not work for you as there we also need to update the binaries. But it would help if you could test if the new audresample binary works on your RaspberryPi as well.

libaudresample.zip

funnyshape commented 1 year ago

Thank you! Unfortunately I get a new error: wrong ELF class: ELFCLASS32

hagenw commented 1 year ago

I guess, I made an error in providing you the ARMv7 binary as you have 64-bit. I attached here a ARMv8 binary that works with 64-bit, could you try again if this works?

linux-armv8.zip

funnyshape commented 1 year ago

Hi, sorry for the late answer! After inserting the file I get a new Error-Message:

OSError: /home/pi1/.local/lib/python3.9/site-packages/opensmile/core/bin/linux/libSMILEapi.so: cannot open shared object file: No such file or directory

Although the file exists in this place.

hagenw commented 1 year ago

Thanks for the feedback. This means audresample does now indeed work on your machine.

The error you are seeing now is due to missing support for ARMv8 in opensmile. We will be able to add it when we have setup the needed scripts to solve https://github.com/audeering/opensmile-python/issues/78 during the next months.

hagenw commented 11 months ago

With release 2.5.0 of opensmile we should now support Raspberry PI. Could you maybe try to update your installation and try again.