Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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 %
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.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.