0

I want to add some sound using playsound, and it worked for a while with no issues. But when I tried to run the code today, it suddenly gave me this error. There are no spaces in the file names.

MacOS Big Sur 11.2.2
Python 3.9.6

from playsound import playsound 

playsound('/Volumes/sDesktop/learnPython/2020simulator/Elegy_AsherFulero.mp3', block = False)
name@names-MBP 2020simulator % /usr/local/bin/python3 "/Volumes/sDesktop 1/learnPython/2020simulator/testScript5.py"
Traceback (most recent call last):
  File "/Volumes/sDesktop 1/learnPython/2020simulator/testScript5.py", line 7, in <module>
    playsound('/Volumes/sDesktop/learnPython/2020simulator/Elegy_AsherFulero.mp3', block = False)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/playsound.py", line 67, in _playsoundOSX
    raise IOError('Unable to load sound named: ' + sound)
OSError: Unable to load sound named: file:///Volumes/sDesktop/learnPython/2020simulator/Elegy_AsherFulero.mp3
name@names-MBP 2020simulator % 
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

1 Answers1

0

well try and re-write the file name or click on the file and click properties. copy the name and see the file type in the shortcut way next to the text where the () are, in there will be file type - delete the file name in the code and paste it then go back to properties and copy the file type in () and paste it after the file name in the code (no spaces) or put the audio file in the same directory and delete the path and only include only the file name and the file type. if neither of these work then uninstall playsound -

pip uninstall playsound

and install in the same path as the py file by using the -t function

pip install -t directory playsound

---------paste the directory here

thanks.