Reputation: 3
I am trying to install librosa on Anaconda environment, I created a completely new and installed librosa, however I keep getting this problem, even when I re-install cffi package, audioread and others. I am not sure how I can fix this problem.
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)
~\.conda\envs\librosa\lib\site-packages\librosa\core\audio.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:
~\.conda\envs\librosa\lib\site-packages\soundfile.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)
~\.conda\envs\librosa\lib\site-packages\soundfile.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:\Users\User\.conda\envs\librosa\Library\bin\sndfile.dll' has no function, constant or global variable named 'sf_wchar_open'
Upvotes: 0
Views: 1461
Reputation: 186
It looks like libsndfile 1.0.29 for conda-forge is broken as of Nov. 5, 2020. Until it has been fixed, the "solutions" as posted on GitHub are to either 1) use pip to install librosa, or 2) in conda, remove libsndfile and install soundfile from pip.
https://github.com/bastibe/SoundFile/issues/278
Upvotes: 1
Reputation: 26
I don't know the real fix for this but deleting that code from soundfile.py
solved it for me.
Just delete the if
loop at line 1170 and modify it to:
if isinstance(file, _unicode):
file = file.encode(_sys.getfilesystemencoding())
The error no longer occurs. I am looking for someone to explain why and how but for now, this works mate!
Upvotes: 1