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时提示此类错误。通过排查发现,在soundfile-0.10.3.post1-py3.7.egg
文件夹下没有_soundfile_data文件夹,自然也就没有libsndfile64bit.dll
文件。
- 解决方法:
(1) 首先在soundfile-0.10.3.post1-py3.7.egg
文件夹下创建一个文件名为_soundfile_data的文件夹
(2)下载libsndfile64bit.dll
文件。推荐一个下载的网址:bastibe/libsndfile-binaries: Pre-compiled shared libraries for libsndfile (github.com),根据自己的电脑配置选择32位或者64位的
(3)将下载的libsndfile64bit.dll文件移到_soundfile_data文件夹下面就ok了。
测试一下: