ctypes.util find_library() couldn't find the .dylib

603 views Asked by At

I want to use a python package called mingus, but it couldn't find the FluidSynth library. However, I have already installed fluidsynth using homebrew (I'm using macOS Catalina), and it sits in the directory /usr/local/Cellar/fluid-synth/2.1.8/lib

The error messages are:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-6003c50a6278> in <module>
----> 1 from mingus.midi import fluidsynth

~/anaconda3/lib/python3.7/site-packages/mingus/midi/fluidsynth.py in <module>
     39 import wave
     40 
---> 41 from mingus.midi import pyfluidsynth as fs
     42 from mingus.midi.sequencer import Sequencer
     43 

~/anaconda3/lib/python3.7/site-packages/mingus/midi/pyfluidsynth.py in <module>
     39 )
     40 if lib is None:
---> 41     raise ImportError("Couldn't find the FluidSynth library.")
     42 
     43 _fl = CDLL(lib)

ImportError: Couldn't find the FluidSynth library.

The code around line 41 in pyfluidsynth.py is:

from ctypes.util import find_library

import six

lib = (
    find_library("fluidsynth")
    or find_library("libfluidsynth")
    or find_library("libfluidsynth-1")
)
if lib is None:
    raise ImportError("Couldn't find the FluidSynth library.")

But I have installed the library in

>> ls -l /usr/local/Cellar/fluid-synth/2.1.8/lib/
total 688
-r--r--r--  1 hqchen  admin  350160 Apr 13 23:12 libfluidsynth.2.3.8.dylib
lrwxr-xr-x  1 hqchen  admin      25 Mar 15 14:12 libfluidsynth.2.dylib -> libfluidsynth.2.3.8.dylib
lrwxr-xr-x  1 hqchen  admin      21 Mar 15 14:12 libfluidsynth.dylib -> libfluidsynth.2.dylib

I think my problem roots on how to add search path in find_library? I have tried to add the path in LD_LIBRARY_PATH and LIBRARY_PATH, but neither works. I appreciate any help!!

0

There are 0 answers