我正试图在Anaconda环境中安装librosa,我创建了一个全新的并安装了librosa的程序,但我一直遇到这个问题,即使我重新安装了cffi包、audioread和其他程序。我不知道怎样才能解决这个问题。
AttributeError Traceback (most recent call last)
<ipython-input-4-d10be33b41bf> in <module>
1 # load files with librosa as a series of floating points
----> 2 debussy, sr = librosa.load(debussy_file)
~.condaenvslibrosalibsite-packageslibrosacoreaudio.py in load(path, sr, mono, offset, duration, dtype, res_type)
144
145 try:
--> 146 with sf.SoundFile(path) as sf_desc:
147 sr_native = sf_desc.samplerate
148 if offset:
~.condaenvslibrosalibsite-packagessoundfile.py in __init__(self, file, mode, samplerate, channels, subtype, endian, format, closefd)
625 self._info = _create_info_struct(file, mode, samplerate, channels,
626 format, subtype, endian)
--> 627 self._file = self._open(file, mode_int, closefd)
628 if set(mode).issuperset('r+') and self.seekable():
629 # Move write position to 0 (like in Python file objects)
~.condaenvslibrosalibsite-packagessoundfile.py in _open(self, file, mode_int, closefd)
1168 if isinstance(file, _unicode):
1169 if _sys.platform == 'win32':
-> 1170 openfunction = _snd.sf_wchar_open
1171 else:
1172 file = file.encode(_sys.getfilesystemencoding())
AttributeError: cffi library 'C:UsersUser.condaenvslibrosaLibrarybinsndfile.dll' has no function, constant or global variable named 'sf_wchar_open'
我不知道真正的解决方案,但从soundfile.py
中删除该代码为我解决了问题。
只需删除第1170行的if
循环,并将其修改为:
if isinstance(file, _unicode):
file = file.encode(_sys.getfilesystemencoding())
错误不再发生。我正在找人来解释为什么以及如何解释,但现在,这个工作伙伴!
截至2020年11月5日,conda-forge的libsndfile 1.0.29似乎已损坏。在它被修复之前;解决方案";在GitHub上发布的是:1(使用pip安装librosa,或者2(在conda中,删除libsndfile并从pip安装soundfile。
https://github.com/bastibe/SoundFile/issues/278