我尝试使用DBUS作为PyQt5的主循环。
全系统
-
python3-pyqt5版本:5.10.1+dfsg-1ubuntu2
-
-
蟒蛇3-dbus.mainloop.pyqt5 版本:5.10.1+dfsg-1ubuntu2
试一试:
$ 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'
我也试过了。但是,我不得不接受系统范围的包,因为我找不到与之相当的pip
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
$ 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
In [1]: from dbus.mainloop.pyqt5 import DBusQtMainLoop
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-ad501d00de5f> in <module>
ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5'
实际上,我想要pyqtv5.12,用于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
In [1]: from dbus.mainloop.pyqt5 import DBusQtMainLoop
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-ad501d00de5f> in <module>
ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5'
的版本dbus.mainloop.
初始化
In [2]: import dbus.mainloop
In [3]: help(dbus.mainloop)
# File location is: /usr/local/lib/python3.6/dist-packages/dbus/mainloop/__init__.py
因此,似乎使用了系统版本。好 啊。
编辑:到目前为止,我可以使用默认值
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
但如果Gtk现在是一个依赖项,那就不能令人满意了。