0

So basically this my code:

from playsound import playsound

playsound('C:\\Users\\arnavb\\Desktop\\Python\\Lecture1\\song.mp3')

And the error I get is:

PS C:\Users\arnavb\Desktop\Python> & C:/Users/arnavb/AppData/Local/Programs/Python/Python39/python.exe c:/Users/arnavb/Desktop/Python/Lecture1/Practice_3.py

    Error 305 for command:
        open "C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3"
    Cannot specify extra characters after a string enclosed in quotation marks.

    Error 263 for command:
        close "C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3"
    The specified device is not open or is not recognized by MCI.
Failed to close the file: "C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3"
Traceback (most recent call last):
  File "c:\Users\arnavb\Desktop\Python\Lecture1\Practice_3.py", line 2, in <module>
    playsound('C:\\Users\\arnavb\\Desktop\\Python\\Lecture1\\song.mp3')
  File "C:\Users\arnavb\AppData\Local\Programs\Python\Python39\lib\site-packages\playsound.py", line 72, in _playsoundWin
    winCommand(u'open {}'.format(sound))
  File "C:\Users\arnavb\AppData\Local\Programs\Python\Python39\lib\site-packages\playsound.py", line 64, in winCommand
    raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
    Error 305 for command:
        open "C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3"
    Cannot specify extra characters after a string enclosed in quotation marks.
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Snake
  • 9
  • 1
  • 2
  • Btw the Python version is 3.9.6 – Snake Aug 20 '21 at 12:01
  • Try:- playsound(r'C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3') –  Aug 20 '21 at 12:19
  • It looks like some internal function is quoting the path because of the embedded backslashes. Try this instead: `playsound('C:/Users/arnavb/Desktop/Python/Lecture1/song.mp3')`. – ekhumoro Aug 20 '21 at 12:35
  • PS: in fact, on Windows, playsound *always* adds double-quotes: https://github.com/TaylorSMarks/playsound/blob/master/playsound.py#L31. It seems like a bug that the documentation doesn't mention this. To get the input path right, it means you should either use forward-slashes or explicitly escape all backslashes, like this: `playsound(r'C:\\Users\\arnavb\\Desktop\\Python\\Lecture1\\song.mp3')` or this `playsound('C:\\\\Users\\\\arnavb\\\\Desktop\\\\Python\\\\Lecture1\\\\song.mp3')`. – ekhumoro Aug 20 '21 at 12:59

1 Answers1

6

Follow this steps :

pip uninstall playsound
pip install playsound==1.2.2