编程语言
首页 > 编程语言> > python – librosa.load:加载文件时找不到文件错误

python – librosa.load:加载文件时找不到文件错误

作者:互联网

我正在尝试使用librosa来分析.wav文件.我开始创建一个列表,该列表存储它检测到的所有.wav文件的名称.

data_dir = '/Users/raghav/Desktop/FSU/summer research'
audio_file = glob(data_dir + '/*.wav')

我可以看到列表’audio_file’中所有文件的名称.但是当我加载任何音频文件时,它会给我找不到文件错误.

audio, sfreq = lr.load(audio_file[0])

错误输出:

Traceback (most recent call last):
  File "read_audio.py", line 10, in <module>
    audio, sfreq = lr.load(audio_file[1])
  File "/usr/local/lib/python3.7/site-packages/librosa/core/audio.py", line 119, in load
    with audioread.audio_open(os.path.realpath(path)) as input_file:    
  File "/usr/local/lib/python3.7/site-packages/audioread/__init__.py", line 107, in audio_open
    backends = available_backends()
  File "/usr/local/lib/python3.7/site-packages/audioread/__init__.py", line 86, in available_backends
    if ffdec.available():
  File "/usr/local/lib/python3.7/site-packages/audioread/ffdec.py", line 108, in available
    creationflags=PROC_FLAGS,
  File "/usr/local/lib/python3.7/site-packages/audioread/ffdec.py", line 94, in popen_multiple
    return subprocess.Popen(cmd, *args, **kwargs)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)

FileNotFoundError: [Errno 2] No such file or directory: 'avconv': 'avconv'

解决方法:

两件事情:

>看起来你正在使用Homebrew
> avconv不在你的道路上

假设您从未安装过它,您应该只需安装即可解决此问题.即跑:

$brew install libav

(见here)

如果已经安装了avconv,您可能需要查看PATH环境并检查它是否在路径中.

也就是说,使用Homebrew安装的系统级Python是一个坏主意,因为它不会很快让你更改Python版本和依赖集.几周内这一切都变成了一大堆.

其中一个(多个)解决方案是使用miniconda.它可以让您快速激活具有已定义依赖集的Python解释器.

所以要真正解决这个问题,我建议安装miniconda并创建一个普通的Python 3.6环境:

$conda create -n librosa_env python=3.6

激活环境:

$source activate librosa_env

然后添加conda-forge通道(包含许多库(如librosa)的存储库):

$conda config --add channels conda-forge

然后安装librosa:

$conda install librosa

通过这种方式安装librosa,conda应该处理所有依赖项,包括. libav.

标签:python,python-3-x,avconv,librosa
来源: https://codeday.me/bug/20191003/1850106.html