我正在尝试在virtualenv中运行dogtail examples。我的virtualenv当前看起来像这样:
$ pip freeze
dogtail==0.9.9
ruamel.yaml==0.15.35
vext==0.7.0
vext.gi==0.6.8
但是,当我尝试运行示例时,我收到一条错误消息,提示
pyatspi
丢失:$ python appstartup.py
Traceback (most recent call last):
File "appstartup.py", line 9, in <module>
from dogtail.procedural import *
File "/home/username/.local/share/virtualenvs/nmtest/lib/python3.6/site-packages/dogtail/procedural.py", line 5, in <module>
from dogtail import rawinput
File "/home/username/.local/share/virtualenvs/nmtest/lib/python3.6/site-packages/dogtail/rawinput.py", line 6, in <module>
from pyatspi import Registry as registry
File "/home/username/.local/share/virtualenvs/nmtest/lib/python3.6/site-packages/vext/gatekeeper/__init__.py", line 204, in load_module
raise ImportError("No module named %s" % modulename)
ImportError: No module named pyatspi
我已经有了
python3-pyatspi
软件包installed,但是显然不能从我的virtualenv内部访问它。 “ pyatspi”没有出现在PyPI上,但是我have found source code。如何在我的virtualenv中安装pyatspi? 最佳答案
由于您的软件包在PyPI上不可用,因此您需要使用系统软件包(包括已安装的pyatspi)创建您的virtualenv:
$ virtualenv --system-site-packages foo
$ source foo/bin/activate
另一个选择是“专有地”包含pyatspi软件包
$ virtualenv --no-site-packages foo
$ source foo/bin/activate
$ ln -s /usr/lib/python3/dist-packages/pyatspi* $VIRTUAL_ENV/lib/python*/site-packages
根据您的环境,命令/路径可能会略有不同。
为了找出pyatspi lib的路径-启动python shell(没有激活的virtualenv),导入模块并检查module_name.path。例如
Python 3.6.4+ (default, Feb 12 2018, 08:25:03)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyatspi
>>> pyatspi.__path__
['/usr/lib/python3/dist-packages/pyatspi']