dbus在虚拟环境中不使用python3?

问题描述 投票:0回答:1

我用virtualwrapper,virtualenv和python3建立了一个名为“Computer Vision”的虚拟环境。

除了在我的python脚本中导入dbus之外,一切正常。我想使用python3,但你可以看到:-dbus可以用python2进行导入而不是python3 -cv2可以用python3进行导入而不用python 2

(ComputerVision) pi@raspberrypi:/ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'dbus'
>>> import cv2
>>> exit()
(ComputerVision) pi@raspberrypi:/ $ python2
Python 2.7.13 (default, Sep 26 2018, 18:42:22) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> exit()
(ComputerVision) pi@raspberrypi:/ $ pip install dbus-python3
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting dbus-python3
  Could not find a version that satisfies the requirement dbus-python3 (from versions: )
No matching distribution found for dbus-python3
(ComputerVision) pi@raspberrypi:/ $ pip install python3-dbus
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting python3-dbus
  Could not find a version that satisfies the requirement python3-dbus (from versions: )
No matching distribution found for python3-dbus
(ComputerVision) pi@raspberrypi:/ $ pip install python-dbus
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting python-dbus
  Could not find a version that satisfies the requirement python-dbus (from versions: )
No matching distribution found for python-dbus
(ComputerVision) pi@raspberrypi:/ $ 

如何修复它,能够将dbus导入我的python3脚本?

先感谢您。

python opencv virtualenv dbus virtualenvwrapper
1个回答
0
投票

您需要为Python3安装dbus-python库:

pip3 install dbus-python
© www.soinside.com 2019 - 2024. All rights reserved.