尝试加载 Librosa 的示例文件时找不到文件错误
File not found error when trying to load Librosa's example file
我正在使用 Librosa 编写我的第一个程序,所以我从他们的文档中复制了一些代码,看看我是否可以让它工作。我在尝试加载示例文件时遇到找不到文件的错误,我不明白为什么。我发现一些人说他们没有后端错误 (https://github.com/librosa/librosa/issues/743, https://github.com/beetbox/audioread/issues/54),我想知道这是否与我的问题有关?我正在使用 PyCharm 如果这会有所作为
这是我的代码:
import librosa
filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)
print(y)
错误信息如下:
Traceback (most recent call last):
File "C:/Users/owner/PycharmProjects/SongVisualizer/SongVisualizer.py", line 11, in <module>
y, sr = librosa.load(filename)
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\librosa\core\audio.py", line 119, in load
with audioread.audio_open(os.path.realpath(path)) as input_file:
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\audioread\__init__.py", line 107, in audio_open
backends = available_backends()
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\audioread\__init__.py", line 86, in available_backends
if ffdec.available():
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\audioread\ffdec.py", line 108, in available
creationflags=PROC_FLAGS,
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\audioread\ffdec.py", line 94, in popen_multiple
return subprocess.Popen(cmd, *args, **kwargs)
File "C:\Python37\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
如有任何帮助,我们将不胜感激
我遇到了同样的问题,并将 return subprocess.Popen(cmd, *args, **kwargs) 行更改为 return subprocess.Popen(cmd, *args, **kwargs, shell = True) 在 ffdec.py 中。它有效,但不建议通过 shell 执行代码。更多详细信息可以从以下位置找到:Actual meaning of 'shell=True' in subprocess
我通过安装 FFmpeg 并将其添加到我的 PATH 变量中解决了我的问题。 Librosa 的音频模块需要 FFmpeg 来加载和操作音频。
我正在使用 Librosa 编写我的第一个程序,所以我从他们的文档中复制了一些代码,看看我是否可以让它工作。我在尝试加载示例文件时遇到找不到文件的错误,我不明白为什么。我发现一些人说他们没有后端错误 (https://github.com/librosa/librosa/issues/743, https://github.com/beetbox/audioread/issues/54),我想知道这是否与我的问题有关?我正在使用 PyCharm 如果这会有所作为
这是我的代码:
import librosa
filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)
print(y)
错误信息如下:
Traceback (most recent call last):
File "C:/Users/owner/PycharmProjects/SongVisualizer/SongVisualizer.py", line 11, in <module>
y, sr = librosa.load(filename)
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\librosa\core\audio.py", line 119, in load
with audioread.audio_open(os.path.realpath(path)) as input_file:
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\audioread\__init__.py", line 107, in audio_open
backends = available_backends()
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\audioread\__init__.py", line 86, in available_backends
if ffdec.available():
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\audioread\ffdec.py", line 108, in available
creationflags=PROC_FLAGS,
File "C:\Users\owner\PycharmProjects\SongVisualizer\venv\lib\site-packages\audioread\ffdec.py", line 94, in popen_multiple
return subprocess.Popen(cmd, *args, **kwargs)
File "C:\Python37\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
如有任何帮助,我们将不胜感激
我遇到了同样的问题,并将 return subprocess.Popen(cmd, *args, **kwargs) 行更改为 return subprocess.Popen(cmd, *args, **kwargs, shell = True) 在 ffdec.py 中。它有效,但不建议通过 shell 执行代码。更多详细信息可以从以下位置找到:Actual meaning of 'shell=True' in subprocess
我通过安装 FFmpeg 并将其添加到我的 PATH 变量中解决了我的问题。 Librosa 的音频模块需要 FFmpeg 来加载和操作音频。