dbus-python 是 Python 與 D-Bus 訊息總整合的橋樑,常用於進程間通訊(IPC)。因官方未提供 setup.py,無法透過 pip 直接安裝,需從原始碼手動編譯。本文記錄完整安裝流程與常見錯誤排解。
wget https://pypi.python.org/packages/source/d/dbus-python/dbus-python-0.84.0.tar.gz
tar zxvf dbus-python-0.84.0.tar.gz
cd dbus-python-0.84.0
執行 ./configure 時可能遇到:
configure: error: Package requirements (dbus-1 >= 1.0) were not met:
No package 'dbus-1' found
原因是系統缺少 D-Bus 開發標頭檔與庫檔。
Ubuntu/Debian 系統:
sudo apt-get install libdbus-glib-1-dev
CentOS/RHEL 系統:
sudo yum install dbus-glib-devel
依賴解決後,依序執行:
./configure
make
sudo make install
python -c "import dbus; print(dbus.__version__)"
python-dev)已安裝python-dbus),優先考慮套件管理器安裝