【问题标题】:Trouble installing Librosa properly (sndfile.dll has not attribute named 'sf_wchar_open')无法正确安装 Librosa(sndfile.dll 没有名为“sf_wchar_open”的属性)
【发布时间】:2020-09-21 09:38:29
【问题描述】:

我正在尝试在 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)

~\.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'

【问题讨论】:

    标签: python anaconda python-3.6 librosa soundfile


    【解决方案1】:

    我不知道解决这个问题的真正方法,但从 soundfile.py 中删除该代码为我解决了这个问题。

    只需删除第 1170 行的if 循环并修改为:

    if isinstance(file, _unicode):
       file = file.encode(_sys.getfilesystemencoding())
    

    错误不再发生。我正在找人解释为什么以及如何,但是现在,这可行!

    【讨论】:

      【解决方案2】:

      截至 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

      【讨论】:

        猜你喜欢
        • 2017-07-23
        • 1970-01-01
        • 1970-01-01
        • 2019-08-23
        • 2021-01-07
        • 1970-01-01
        • 2017-03-21
        • 2017-04-26
        • 2019-01-07
        相关资源
        最近更新 更多