mk-fg / python-pulse-control

Python high-level interface and ctypes-based bindings for PulseAudio (libpulse)
https://pypi.org/project/pulsectl/
MIT License
170 stars 36 forks source link

error on macbook : "OSError: dlopen(libpulse.so.0, 6): image not found" #34

Closed janvda closed 4 years ago

janvda commented 4 years ago

I am getting below error on my macbook:

Jans-MBP:tmp jan$ python3
Python 3.7.4 (v3.7.4:e09359112e, Jul  8 2019, 14:54:52) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pulsectl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pulsectl/__init__.py", line 4, in <module>
    from . import _pulsectl
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pulsectl/_pulsectl.py", line 669, in <module>
    pa = LibPulse()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pulsectl/_pulsectl.py", line 621, in __init__
    p = CDLL('libpulse.so.0')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libpulse.so.0, 6): image not found
>>> 

Note that pulseaudio is installed on my macbook when trying to import pulsectl

Jans-MBP:tmp jan$ pulseaudio --version
W: [] caps.c: Normally all extra capabilities would be dropped now, but that's impossible because PulseAudio was built without capabilities support.
pulseaudio 13.0
Jans-MBP:tmp jan$ 
mk-fg commented 4 years ago

Congratulations on being first user of the module on OSX, apparently :)

Problem is CDLL('libpulse.so.0'), which tries to open .so file as it says, but I think OSX uses .dynlib files with probably some different versioning convention, so that filename just has to be different for OSX. Iirc python ctypes had some wrapper to abstract these, will check if maybe it can be fixed without needing to learn much about lib names there.

Thanks for reporting.

mk-fg commented 4 years ago

Replaced that CDLL with p = CDLL(ctypes.util.find_library('libpulse') or 'libpulse.so.0') in 19.10.0. I think it should work if you have libpulse installed in a proper way for OSX.

Don't have macbook to test it, so let me know if it still won't work. Maybe also check what's the full path to libpulse if that's the case, and maybe run something like strace -s16384 python3 -c 'import pulsectl' 2>&1 | grep libpulse if you can (not sure if OSX has strace though), as that should probably show where python ctypes module and/or libdl is looking for it.

janvda commented 4 years ago

Thanks for the extreme fast resolution. The issue is indeed gone when installing version 19.10.0.
Jan.