Python-子流程FileNotFoundError:[WinError 2]

Python-子流程FileNotFoundError:[WinError 2],python,selenium,pydub,Python,Selenium,Pydub,我正在尝试运行此reCaptcha代码,我已经非常接近了,但我遇到了以下错误: File "search_bot.py", line 53, in solveReCaptcha sound = pydub.AudioSegment.from_mp3(os.getcwd()+"\\sample.mp3") File "C:\Users\username\AppData\Local\Programs\Python\Python36-3

我正在尝试运行此reCaptcha代码,我已经非常接近了,但我遇到了以下错误:

  File "search_bot.py", line 53, in solveReCaptcha
    sound = pydub.AudioSegment.from_mp3(os.getcwd()+"\\sample.mp3")
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pydub\audio_segment.py", line 738, in from_mp3
    return cls.from_file(file, 'mp3', parameters=parameters)
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pydub\audio_segment.py", line 685, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
它在一个.py文件上抛出了一个错误,我甚至没有编写这个文件,但它只是Python库的一部分,所以我不知道如何修复它,甚至不知道为什么要得到它。我已经看过了,但没用

编辑:

这是引发错误的代码:

urllib.request.urlretrieve(src, os.getcwd() + "\\sample.mp3")
sound = pydub.AudioSegment.from_mp3(os.getcwd() + "\\sample.mp3")
sound.export(os.getcwd() + "\\sample.wav", format="wav")
sample_audio = sr.AudioFile(os.getcwd() + "\\sample.wav")
r = sr.Recognizer()

错误消息指向在执行scritp的目录中找不到sample.np3。您可以尝试替换
os.path.join(os.path.dirname(\uuuu file\uuuu),'sample.mp3')的路径。

文件sample.mp3与.py文件位于同一目录中
os.getcwd()+“\\sample.mp3”
是我首先添加文件的方式,因此它应该可以用来读取文件。我添加了代码,因此您可以看到它是如何工作的。请尝试使用
os.path.join
而不是使用
+
来连接路径名。Python将为您构建路径,而不必担心兼容性问题。