1
我有運行示例Python代碼這是在Ubuntu桌面罰款:Python的DBUS SESSION_BUS - X11依賴
import dbus, gobject
from dbus.mainloop.glib import DBusGMainLoop
from dbus.mainloop.glib import threads_init
import subprocess
from subprocess import call
gobject.threads_init()
threads_init()
dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
p = subprocess.Popen('dbus-launch --sh-syntax', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
call("export DBUS_SESSION_BUS_ADDRESS" , shell=True)
call("export DBUS_SESSION_BUS_PID" , shell=True)
bus = dbus.SessionBus()
# get DBUS objects, do other stuff with SESSION_BUS
# in same time we can start more independent processes with this file
# finaly kill the SESSION_BUS process
桌面上的成功後,我搬到了代碼的服務器版本是隻與外殼。 dbus-launch啓動進程,但python dbus.SessionBus()返回錯誤,「/ bin/dbus-launch異常終止,出現以下錯誤:Autolaunch error:X11 initialization failed」。
希望SESSION_BUS和X11之間不應該存在嚴格的依賴關係,因爲當「dbus-launch」開始的進程啓動並且成功運行時。該錯誤出現在python中。
最好的解決方案將是乾淨的蟒蛇或Linux環境的設置,最糟糕但也有一些假的或虛擬的X11(我是不是很幸運,當我嘗試)
大,os.environ做的工作!謝謝。 – 2010-01-27 10:15:52