解决 FileNotFoundError: [WinError 2] 系统找不到指定的文件

编程过程中我遇到这种问题:

Traceback (most recent call last):
  File "C:\Users\asus\Desktop\High and Low Pass Filtering.py", line 26, in <module>
    wav = AudioSegment.from_wav("1.wav")
  File "D:\soft2\python\Pythonfiles\lib\site-packages\pydub\audio_segment.py", line 728, in from_wav
    return cls.from_file(file, 'wav', parameters=parameters)
  File "D:\soft2\python\Pythonfiles\lib\site-packages\pydub\audio_segment.py", line 665, in from_file
    info = mediainfo_json(orig_file)
  File "D:\soft2\python\Pythonfiles\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "D:\soft2\python\Pythonfiles\lib\subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "D:\soft2\python\Pythonfiles\lib\subprocess.py", line 1155, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

解决方法:

根据提示找到lib中的subprocess.py文件(比如小编的就是 D:\soft2\python\Pythonfiles\lib\subprocess.py) ,查找class Popen模块,再将这个模块中的
__init__函数中的shell = False 改成shell = True

在这里插入图片描述

发布了86 篇原创文章 · 获赞 8 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/tscaxx/article/details/104366099