Errno 2 没有这样的文件或目录:ffprobe

问题描述 投票:0回答:1

我通过下面的 Anaconda 菜单运行 Spyder。

enter image description here

然后我运行一个 .py 文件,将 .m4a 文件转换为 .mp3。

import os
import pydub
import glob

m4a_files = glob.glob('./*.m4a')

all_files = [m4a_files]

for files in all_files:
    for file in files:
        mp3_file = os.path.splitext(file)[0] + '.mp3'
        sound = pydub.AudioSegment.from_file(file)
        print("Converting: ",file)
        sound.export(mp3_file, format="mp3")
        os.remove(file)
        print("Conversion Complete")`

它给出了以下错误:

    runfile('/Users/MyName/Library/CloudStorage/OneDrive-Personal/Bibliothek/Deutsch/Wörterbuch/Soundaufnahmen/Wörterbuch_2000-3000_Original_Non-Equilazed/Converter_1.py', wdir='/Users/MyName/Library/CloudStorage/OneDrive-Personal/Bibliothek/Deutsch/Wörterbuch/Soundaufnahmen/Wörterbuch_2000-3000_Original_Non-Equilazed')
    /Users/MyName/anaconda3/lib/python3.11/site-packages/pydub/utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
      warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
    Traceback (most recent call last):
    
      File ~/anaconda3/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
        exec(code, globals, locals)
    
      File ~/Library/CloudStorage/OneDrive-Personal/Bibliothek/Deutsch/Wörterbuch/Soundaufnahmen/Wörterbuch_2000-3000_Original_Non-Equilazed/Converter_1.py:26
        sound = pydub.AudioSegment.from_file(file)
    
      File ~/anaconda3/lib/python3.11/site-packages/pydub/audio_segment.py:728 in from_file
        info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
    
      File ~/anaconda3/lib/python3.11/site-packages/pydub/utils.py:274 in mediainfo_json
        res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
    
      File ~/anaconda3/lib/python3.11/subprocess.py:1024 in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
    
      File ~/anaconda3/lib/python3.11/subprocess.py:1917 in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)

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

我可以在以下目录中看到一个名为“ffprobe”的文件夹:

/Users/MyName/anaconda3/lib/python3.11/site-packages

我尝试了以下方法

sys.path.append('/Users/MyName/anaconda3/lib/python3.11/site-packages')
sys.path.append('/Users/MyName/anaconda3/lib/python3.11/site-packages/ffprobe')

但是没有成功。

我还尝试使用 Tools/PYTHONPATH Manager 将上面的两个目录添加到路径中。但是我无法让这些目录显示在下面的目录列表中:

enter image description here

你能帮我解决这个问题吗?

非常感谢大家抽出宝贵的时间。

python path anaconda spyder ffprobe
1个回答
0
投票

我刚刚通过在终端中使用以下命令安装 ffmpeg 解决了该问题。

conda install ffmpeg
© www.soinside.com 2019 - 2024. All rights reserved.