解决“OSError: cannot load library ‘libsndfile.so‘ ”问题

唐健
2023-12-01

问题描述

在安装完librosa之后,运行程序报错“OSError: cannot load library 'libsndfile.so': libsndfile.so: cannot open shared object file: No such file or directory”

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/soundfile.py", line 151, in <module>
    raise OSError('sndfile library not found')
OSError: sndfile library not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/soundfile.py", line 178, in <module>
    _snd = _ffi.dlopen(_os.path.join(_path, '_soundfile_data', _packaged_libname))
OSError: cannot load library '/usr/local/lib/python3.6/dist-packages/_soundfile_data/libsndfile.so': /usr/local/lib/python3.6/dist-packages/_soundfile_data/libsndfile.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "train_bilstm_model.py", line 1, in <module>
    import BiLSTM.bilstm_speech_seg_train as train_engine
  File "/share/speech_seg/BiLSTM/bilstm_speech_seg_train.py", line 10, in <module>
    from BiLSTM.prepare_dataset import load_dataset
  File "/share/speech_seg/BiLSTM/prepare_dataset.py", line 1, in <module>
    import librosa
  File "/usr/local/lib/python3.6/dist-packages/librosa/__init__.py", line 209, in <module>
    from . import core
  File "/usr/local/lib/python3.6/dist-packages/librosa/core/__init__.py", line 6, in <module>
    from .audio import *  # pylint: disable=wildcard-import
  File "/usr/local/lib/python3.6/dist-packages/librosa/core/audio.py", line 8, in <module>
    import soundfile as sf
  File "/usr/local/lib/python3.6/dist-packages/soundfile.py", line 189, in <module>
    _snd = _ffi.dlopen(_libname)
OSError: cannot load library 'libsndfile.so': libsndfile.so: cannot open shared object file: No such file or directory

解决方法

apt install libsndfile1

即可

 类似资料: