0

i tried to play a music file but failed

from playsound import playsound
playsound('play.mp3')

but it shows the error

Error 277 for command:
    open play.mp3
A problem occurred in initializing MCI

also tried this before

from playsound import playsound
playsound('C:\\Users\\Usman\\Music\\My music//play.mp3') 

but this error showed up

Traceback (most recent call last):
File "c:\Users\Usman\Downloads\Python Course with Notes\1. Chapter 1\01-prob3.py", line 2, in 
<module>
playsound('C:\\Users\\Usman\\Music\\My music//play.mp3')
File "C:\Users\Usman\AppData\Local\Programs\Python\Python310\lib\site-packages\playsound.py", 
line 41, in _playsoundWin
copy(sound, tempPath)
File "C:\Users\Usman\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 417, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Users\Usman\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 254, in 
copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Usman\\Music\\My 
music//play.mp3'
PS C:\Users\Usman\Downloads\Python Course with Notes\1. Chapter 1>

first one enter image description here enter image description here

second one enter image description here the path: enter image description here

what am i doing wrong? pls help

  • your file path is using mixed forward and backward slashes. that's probably causing the file to not be found... – Aaron Jun 28 '22 at 16:07
  • tried that as well bro same issue @Aaron – Muhammad Usman Jun 28 '22 at 16:55
  • you have 2 different issues at hand here... fixing the file path should fix the `FileNotFoundError` I haven't looked in to what can cause the other error message. – Aaron Jun 28 '22 at 17:12
  • ok @Aaron i have added some pics to explain more , pls look into it – Muhammad Usman Jun 28 '22 at 17:38
  • don't use double forward slashes. we can't really help you solve a file not found error - this isn't a music library problem - you just need to correctly reference the file. try debugging with something simpler like `os.listdir` or `os.isfile`. good luck! – Michael Delgado Jun 28 '22 at 17:42

0 Answers0