![](/img/trans.png)
[英]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
[英]When I try to open a wave file in pydub, it can't find the file. Why is this?
這是終端的外觀:
>>> 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
現在,此文件肯定存在於我的計算機上,據我所知,我正確使用了反斜杠。 為什么Python無法找到它?
仔細看看該回溯-找不到WAV文件,找不到可執行文件(由conversion_command
引用)。 根據Pydub文檔,WAV文件不需要外部命令,因此我懷疑您擁有的文件實際上不是有效的WAV。 如果文件是其他格式的有效文件,則可以嘗試按照Pydub文檔中的說明安裝其可選依賴項(libav,ffmpeg)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.