How to fix "Unable to load sound" error with Python Playsound Module?

Solution 1:

I have found where the problem is. In the python3.7/site-packages/playsound.py file The developer has not checked for " " spaces in file path, so spaces character in the file path is creating trouble.

A quick fix without changing playsound.py 's code. replace your folder name ~/Desktop/Python Projects/Sound Test/test.wav with ~/Desktop/PythonProjects/SoundTest/test.wav

(i.e, remove spaces from folder names)

This will fix your error.

Solution 2:

This allows it to work...

s_musicfile = "/Users/xxxxxxxxxx/Desktop/play this file.mp3"

s_musicfile = s_musicfile.replace(" ", "%20")

playsound(s_musicfile)