I am trying to use DBUS as the main loop of PyQt5.
System-wide
I installed, system-wide (with apt, LinuxMint 19, amd64), the following dependencies:
- python3-pyqt5 Version: 5.10.1+dfsg-1ubuntu2
- python3-dbus Version: 1.2.6-1
- python3-dbus.mainloop.pyqt5 Version: 5.10.1+dfsg-1ubuntu2
Trying it:
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from dbus.mainloop.pyqt5 import DBusQtMainLoop
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5'
In a virtual env
I tried in a venv too. However, I had to accept system-wide packages, because I can't find a pip equivalent of python3-dbus.mainloop.pyqt5
.
virtualenv --python=/usr/bin/python3 ~/.venvs/python3/testqtdbus5 --system-site-packages
source ~/.venvs/python3/testqtdbus5/bin/activate
$ pip install "pyqt5==5.10" dbus-python
Collecting pyqt5==5.10
Using cached https://files.pythonhosted.org/packages/ae/4b/c7315ba7a266d493ee50c4597b1b4dea2348896a49115b5192b21adf1a47/PyQt5-5.10-5.10.0-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl
Requirement already satisfied: dbus-python in /usr/local/lib/python3.6/dist-packages (1.2.8)
Collecting sip<4.20,>=4.19.4 (from pyqt5==5.10)
Using cached https://files.pythonhosted.org/packages/8a/ea/d317ce5696dda4df7c156cd60447cda22833b38106c98250eae1451f03ec/sip-4.19.8-cp36-cp36m-manylinux1_x86_64.whl
ERROR: pyqtwebengine 5.12.1 has requirement PyQt5>=5.12, but you'll have pyqt5 5.10 which is incompatible.
Installing collected packages: sip, pyqt5
Found existing installation: PyQt5 5.12
Not uninstalling pyqt5 at /usr/local/lib/python3.6/dist-packages, outside environment /home/vince/.venvs/python3/testqtdbus5
Can't uninstall 'PyQt5'. No files were found to uninstall.
Successfully installed pyqt5-5.10 sip-4.19.8
Trying:
$ ipython
/home/vince/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py:925: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
warn("Attempting to work in a virtualenv. If you encounter problems, please "
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from dbus.mainloop.pyqt5 import DBusQtMainLoop
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-ad501d00de5f> in <module>
----> 1 from dbus.mainloop.pyqt5 import DBusQtMainLoop
ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5'
Actually I want pyqt v5.12, for the WebEngine.
$ pip install "pyqt5==5.12.2" dbus-python
Collecting pyqt5==5.12.2
Downloading https://files.pythonhosted.org/packages/6a/f4/6a63aafcee3efd2b156dc835d9c85ca99b24e80f8af89b6da5c46054fe43/PyQt5-5.12.2-5.12.3-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl (61.5MB)
|████████████████████████████████| 61.5MB 362kB/s
Requirement already satisfied: dbus-python in /usr/local/lib/python3.6/dist-packages (1.2.8)
Requirement already satisfied: PyQt5_sip<13,>=4.19.14 in /home/vince/.local/lib/python3.6/site-packages (from pyqt5==5.12.2) (4.19.15)
Installing collected packages: pyqt5
Found existing installation: PyQt5 5.10
Uninstalling PyQt5-5.10:
Successfully uninstalled PyQt5-5.10
Successfully installed pyqt5-5.12.2
$ ipython
/home/vince/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py:925: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
warn("Attempting to work in a virtualenv. If you encounter problems, please "
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from dbus.mainloop.pyqt5 import DBusQtMainLoop
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-ad501d00de5f> in <module>
----> 1 from dbus.mainloop.pyqt5 import DBusQtMainLoop
ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5'
Version of dbus.mainloop.init.py
In [2]: import dbus.mainloop
In [3]: help(dbus.mainloop)
# File location is: /usr/local/lib/python3.6/dist-packages/dbus/mainloop/__init__.py
So it seems the system version is used. Ok.
What am I missing ? Is there a pip package for the dbus mainloop ? Thanks.
edit: So far, I can work with the default
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
But if Gtk is now a dependency, that isn't satisfactory.