解決import librosa報(bào)錯cannot load library soundfile-0.10.3.post1-py3.7.egg\_soundfile_data\libsndfile...

In [2]: import librosa
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
c:\users\zlyx1\.conda\envs\tf2_3_gpu\lib\site-packages\soundfile-0.10.3.post1-py3.7.egg\soundfile.py in <module>
    141     if _libname is None:
--> 142         raise OSError('sndfile library not found')
    143     _snd = _ffi.dlopen(_libname)

OSError: sndfile library not found

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
<ipython-input-2-989066361697> in <module>
----> 1 import librosa

c:\users\zlyx1\.conda\envs\tf2_3_gpu\lib\site-packages\librosa\__init__.py in <module>
     10 # And all the librosa sub-modules
     11 from ._cache import cache
---> 12 from . import core
     13 from . import beat
     14 from . import decompose

c:\users\zlyx1\.conda\envs\tf2_3_gpu\lib\site-packages\librosa\core\__init__.py in <module>
    124
    125 from .time_frequency import *  # pylint: disable=wildcard-import
--> 126 from .audio import *  # pylint: disable=wildcard-import
    127 from .spectrum import *  # pylint: disable=wildcard-import
    128 from .pitch import *  # pylint: disable=wildcard-import

c:\users\zlyx1\.conda\envs\tf2_3_gpu\lib\site-packages\librosa\core\audio.py in <module>
      8 import warnings
      9
---> 10 import soundfile as sf
     11 import audioread
     12 import numpy as np

c:\users\zlyx1\.conda\envs\tf2_3_gpu\lib\site-packages\soundfile-0.10.3.post1-py3.7.egg\soundfile.py in <module>
    161
    162     _snd = _ffi.dlopen(_os.path.join(
--> 163         _path, '_soundfile_data', _libname))
    164
    165 __libsndfile_version__ = _ffi.string(_snd.sf_version_string()).decode('utf-8', 'replace')

OSError: cannot load library 'c:\users\zlyx1\.conda\envs\tf2_3_gpu\lib\site-packages\soundfile-0.10.3.post1-py3.7.egg\_soundfile_data\libsndfile64bit.dll': error 0x7e

在import librosa時提示此類錯誤。通過排查發(fā)現(xiàn),在soundfile-0.10.3.post1-py3.7.egg文件夾下沒有_soundfile_data文件夾,自然也就沒有libsndfile64bit.dll文件。

  • 解決方法:
    (1) 首先在soundfile-0.10.3.post1-py3.7.egg文件夾下創(chuàng)建一個文件名為_soundfile_data的文件夾
    (2)下載libsndfile64bit.dll文件。推薦一個下載的網(wǎng)址:bastibe/libsndfile-binaries: Pre-compiled shared libraries for libsndfile (github.com),根據(jù)自己的電腦配置選擇32位或者64位的
    (3)將下載的libsndfile64bit.dll文件移到_soundfile_data文件夾下面就ok了。
    測試一下:
    此時可以正常導(dǎo)入了。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容