Why does he give me The system cannot find the file specified

I am writing a program that contains several libraries
I run a function every time I want to call it and I get the following error:

line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

The function is to play an audio file in mp3 format
They are as follows:

def welcome():
    music = AudioSegment.from_mp3('sounds/welcome.mp3')
    play(music)

welcome()

I trust you

I assume you’re using pydub. Based on the definition of its play() function, I assume you don’t have simpleaudio or pyaudio installed. It falls back on trying “ffplay” via subprocess. First, it tries to determine whether to use “avplay” or “ffplay” in get_player_name(). It defaults to using “ffplay” if neither “avplay” nor “ffplay” is found via which(), just to give the OS a chance to find the command. In Windows, subprocess.Popen calls _winapi.CreateProcess(), which fails with FileNotFoundError if the command can’t be found.

3 Likes

So what is the solution?!

Try pip installing one the following packages: simpleaudio or pyaudio. If one doesn’t work, try the other. If neither works, download ffmpeg essentials and manually install it. Extract the 7z or zip archive, and add the full path of the “bin” directory that contains “ffplay.exe” to PATH.

1 Like