Click here to Skip to main content
15,906,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been making a some stupid code and i'm trying to play a sound. However when I run the code (without the timer and such so I can test if it works) I get this error:
Traceback (most recent call last):
  File "C:/Users/hpdes/Desktop/Corona", line 7, in <module>
    playsound('Cough 2.wav')
  File "C:\Users\hpdes\AppData\Local\Programs\Python\Python38-32\lib\site-packages\", line 35, in _playsoundWin
    winCommand('open "' + sound + '" alias', alias)
  File "C:\Users\hpdes\AppData\Local\Programs\Python\Python38-32\lib\site-packages\", line 31, in winCommand
    raise PlaysoundException(exceptionMessage)
    Error 275 for command:
        open "Cough 2.wav" alias playsound_0.022396715181163374
    Cannot find the specified file.  Make sure the path and filename are correct.

The file is on my computer but for some reason it can't be found. I'm new to this stuff so please excuse me being an idiot. The code is designed to randomly have a chance to cough every 20 seconds. Here is the code:

 from playsound import playsound
import time
from random import randint
import random

def countdown(n):
    n == 20
    n = n - 1
    if n == 0:

#Random choice
list = [1,2,3,4,5]
random.str = random.choice(list)
if random.str == 3:

#(Im getting the error here)
 playsound('Cough 2.wav')

What I have tried:

I've tried changing the file type though I think it has to do with the path.
Updated 18-Jul-20 20:44pm

1 solution

The last line of the error trace says it all ..
Printer Overlord wrote:
Cannot find the specified file. Make sure the path and filename are correct.

I think you'd be better off with a fully qualified path to the file for example
playsound('C:/Users/hpdes/Desktop/Cough 2.wav')
- obviously you'll need to change that to the actual file location
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900