4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【備忘録】pythonのplaysoundがGst関連エラーで動かなかったら

Posted at

症状

↓のようなエラーが出て再生できなかった (Raspberry Pi OS @ Raspberry Pi 2B)

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 261, in <module>
    playsound(argv[1])
  File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 163, 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
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 254, in <lambda>
    playsound = lambda sound, block = True: _playsoundAnotherPython('/usr/bin/python3', sound, block, macOS = False)
  File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 229, in _playsoundAnotherPython
    t.join()
  File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 218, in join
    raise self.exc
  File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 211, in run
    self.ret = self._target(*self._args, **self._kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 226, in <lambda>
    t = PropogatingThread(target = lambda: check_call([otherPython, playsoundPath, _handlePathOSX(sound) if macOS else sound]))
  File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '/home/pi/.local/lib/python3.7/site-packages/playsound.py', 'chime.mp3']' returned non-zero exit status 1.

解決方法

GitHubのissueに解決策がありました。
python版gstreamerが入っていないことが原因らしいので

sudo apt install python3-gst-1.0

でちゃんと音声が再生されるようになります。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?