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)入了。
