简体   繁体   English

当我尝试在pydub中打开wave文件时,找不到该文件。 为什么是这样?

[英]When I try to open a wave file in pydub, it can't find the file. Why is this?

Here is what the terminal looks like: 这是终端的外观:

>>> from pydub import AudioSegment
>>> song = AudioSegment.from_wav("E:\\sounds\\ahh.wav")

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    song = AudioSegment.from_wav("E:\\sounds\\ahh.wav")
  File "C:\Python27\lib\pydub\audio_segment.py", line 534, in from_wav
    return cls.from_file(file, 'wav', parameters)
  File "C:\Python27\lib\pydub\audio_segment.py", line 505, in from_file
    p = subprocess.Popen(conversion_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Now, this file DEFINITELY DOES exist on my computer, and as far as I know I used the backslashes correctly. 现在,此文件肯定存在于我的计算机上,据我所知,我正确使用了反斜杠。 Why isn't Python able to find it? 为什么Python无法找到它?

Take a closer look at that traceback - it isn't your WAV file that isn't being found, it's an executable program (referred to by conversion_command ) that isn't found. 仔细看看该回溯-找不到WAV文件,找不到可执行文件(由conversion_command引用)。 According to the Pydub docs, no external command is needed for WAV files, so I suspect that the file you have isn't actually a valid WAV. 根据Pydub文档,WAV文件不需要外部命令,因此我怀疑您拥有的文件实际上不是有效的WAV。 You could try following the instructions in the Pydub docs for installing its optional dependencies (libav, ffmpeg), in case the file is a valid file of a different format. 如果文件是其他格式的有效文件,则可以尝试按照Pydub文档中的说明安装其可选依赖项(libav,ffmpeg)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试读取日志文件。 它使用记事本作为txt文件打开。 但是,当我尝试使用python读取文件时,它无法打开 - I am trying to read a log file. It opens using notepad as txt file. However when I try using python to read the file it doesn't open Pydub 系统找不到指定的文件 - Pydub The system can not find the file specified 当我尝试导出 Mp3 的一部分时,pydub 返回零字节文件 - pydub returning zero byte file when I try to export part of an Mp3 当我打开要首先写入的文件时,为什么在File.open中无法读取任何内容? - Why I can't read anything with File.open in python when I open the file to write first? 当我尝试在Docker容器中运行Shell脚本时无法打开文件 - Can't open file when i try to run a shell script inside Docker container 使用 Python/FFMPEG/Pydub 将 Wave 文件的部分静音 - Mute parts of Wave file using Python/FFMPEG/Pydub Pydub (WindowsError: [错误2] 系统找不到指定的文件) - Pydub (WindowsError: [Error 2] The system can not find the file specified) 音频段大文件时pydub可以不导致内存错误吗? - Can pydub don't lead to memory error when audio segment big file? 为什么我不能在 PyDub 中使用“play()”函数? - Why I can't use “play()” function in PyDub? 如何在pydub中获得相同的输入和输出文件比特率? - How can I get the same bitrate of input and output file in pydub?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM