【问题标题】:FileNotFoundError while using the pydub library使用 pydub 库时出现 FileNotFoundError
【发布时间】:2022-07-12 00:22:07
【问题描述】:

这就是我所拥有的:

from pydub import AudioSegment

AudioSegment.from_file("Somesong.webm").export("Samesong.mp3", format="mp3")

“Somesong.webm”与脚本位于同一目录中,但是,我收到此错误:

C:\Users\User\AppData\Roaming\Python\Python39\site-packages\pydub\utils.py:170: 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\User\AppData\Roaming\Python\Python39\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 "c:\Users\User\Documents\Projects\.vscode\Python\GD SONG REPLACE\main.py", line 24, in <module>
    AudioSegment.from_file("Creo - Sphere.webm").export("Creo - Sphere.mp3", format="mp3")
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\pydub\audio_segment.py", line 728, in from_file
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Program Files\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

我也试过输入文件的绝对路径,但错误不会消失。

【问题讨论】:

    标签: python pydub


    【解决方案1】:

    如果它们在同一目录中,请尝试将“Somesong.webm”更改为“.\Somesong.webm”,将“Samesong.mp3”更改为“.\Samesong.mp3”。这 ”。”表示该文件应与代码存在于同一目录中。

    编辑:请注意,这是假设它是与文件相关的问题。它可能是别的东西。我本来想发表评论的,但我没有足够的声誉这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多