I have a Python script on a Raspberry Pi that streams radio. It was working great for a long time, but today not so much. Here is a reproducible example that produces the error message:
import pygst
import gst
import time
import subprocess
def on_tag(bus, msg):
taglist = msg.parse_tag()
print 'on_tag:'
for key in taglist.keys():
print '\t%s = %s' % (key, taglist[key])
#our stream to play
music_stream_uri = "http://streams.kqed.org/kqedradio"
##
###creates a playbin (plays media form an uri)
player = gst.element_factory_make("playbin", "player")
##
###set the uri
player.set_property('uri', music_stream_uri)
##
###start playing
player.set_state(gst.STATE_PLAYING)
#listen for tags on the message bus; tag event might be called more than once
bus = player.get_bus()
bus.enable_sync_message_emission()
bus.add_signal_watch()
bus.connect('message::tag', on_tag)
#wait and let the music play
raw_input('Press enter to stop playing...')
And here is the error message:
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
** (test.py:2844): WARNING **: Cannot autolaunch D-Bus without X11 $DISPLAY
Press enter to stop playing...Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
This answer says the part about the display is harmless and I believe I've seen that message before with no problems playing the radio stream. I tried this answer, but it also returns an error about the display (not sure what pulseradio is, but I tried it as per the answer).
pi@raspberrypi ~ $ pulseaudio --kill
-bash: pulseaudio: command not found
pi@raspberrypi ~ $ jack_control start
Traceback (most recent call last):
File "/usr/bin/jack_control", line 374, in <module>
main()
File "/usr/bin/jack_control", line 135, in main
bus = dbus.SessionBus()
File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 211, in __new__
mainloop=mainloop)
File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 100, in __new__
bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 122, in __new__
bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
It's worth noting as this point that there is no display, I am accessing the Raspberry Pi through PuTTY. This question has a very similar problem, but I don't see how this answer applies to my script. This answer (also to a very similar question) suppresses the X11 error, but I still get the error about the jackbus:
Press enter to stop playing...Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
Finally, I reset alsamixer to no avail sudo /etc/init.d/alsa-utils reset
Update
I am a genius. It turns out I accidentally plugged the audio output cable into the headphone jack of my speakers instead of the audio input jack. Apparently I've always been getting this error message and never noticed it because I still get sound no problem (at least as long as I don't screw up the cables!). I would still be interested in an explanation of this error message because it turns out it's completely erroneous and the raspberry pi is indeed outputting sound.