开发者社区> 问答> 正文

子进程-startupinfo-FileNotFoundError

我试图运行此代码

filepath = "C:/Users/Linus/Desktop/Test/Audio/"     #Input audio file path


from pydub import AudioSegment
import os

def mp3_to_wav(audio_file_name):
    if audio_file_name.split('.')[1] == 'mp3':    
        sound = AudioSegment.from_mp3(audio_file_name)
        audio_file_name = audio_file_name.split('.')[0] + '.wav'
        sound.export(audio_file_name, format="wav")

if __name__ == "__main__":
    for audio_file_name in os.listdir(filepath): 
        file_name = filepath + audio_file_name
        file_name = os.path.realpath(file_name)
        mp3_to_wav(file_name)

但我在下面(最后一行)出现此错误

runfile('C:/Users/Linus/Desktop/Test/test2.py', wdir='C:/Users/Linus/Desktop/Test')
C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\utils.py:165: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\utils.py:193: 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 "<ipython-input-1-b871056654c0>", line 1, in <module>
    runfile('C:/Users/Linus/Desktop/Test/test2.py', wdir='C:/Users/Linus/Desktop/Test')

  File "C:\Programme\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Programme\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Linus/Desktop/Test/test2.py", line 22, in <module>
    mp3_to_wav(file_name)

  File "C:/Users/Linus/Desktop/Test/test2.py", line 14, in mp3_to_wav
    sound = AudioSegment.from_mp3(audio_file_name)

  File "C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\audio_segment.py", line 716, in from_mp3
    return cls.from_file(file, 'mp3', parameters=parameters)

  File "C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\audio_segment.py", line 665, in from_file
    info = mediainfo_json(orig_file)

  File "C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\utils.py", line 263, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)

  File "C:\Programme\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 143, in __init__
    super(SubprocessPopen, self).__init__(\*rgs, \*kwargs)

  File "C:\Programme\Anaconda3\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)

  File "C:\Programme\Anaconda3\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)

FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

最后一行是德语,表示“系统找不到指定的文件”。

我在很多论坛上都读了很多书,但找不到任何解决方案。我是Python编程(以及Generell编程)的新手,我不知道该怎么做。如果有人可以帮助,那就太好了。

问题来源:stackoverflow

展开
收起
is大龙 2020-03-24 19:27:16 549 0
1 条回答
写回答
取消 提交回答
  • Ich glaube,Dass Sie FFMPEG nicht installiert haben。Ihrem程序中deinem路径中的Mach malpip install ffmpeg和dann enweder schreiben Sie das:`AudioSegment.ffmpeg =“ C:\ path \ path \ ffmpeg.exe” gerade Deutsch,也对不起wenn ich etwas flasch geschrieben habe :)

    回答来源:stackoverflow

    2020-03-24 19:27:25
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载