Search code examples
pythonpython-playsound

"Namespace Gst not available" error when using playsound module in Raspbian os


I recently came across the playsound module and I tried my Python IDE in my Raspbian os it's giving me some error:

from playsound import playsound

playsound('/home/pi/mu_code/music.mp3')

This code is getting me error:

Traceback (most recent call last):
  File "/home/pi/mu_code/pl.py", line 2, in <module>
    playsound('/home/pi/mu_code/music.mp3')
  File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 92, in _playsoundNix
    gi.require_version('Gst', '1.0')
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 129, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available

Solution

  • Try using double bars rewriting the mp3 path and tell me if it works. If it doesn't, try using the absolute path instead of a shorter one.

    from playsound import playsound
    playsound('//home//pi//mu_code//music.mp3')