Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install pyatspi in a virtualenv?

Tags:

python

gnome

I am trying to run the dogtail examples in a virtualenv. My virtualenv currently looks like this:

$ pip freeze
dogtail==0.9.9
ruamel.yaml==0.15.35
vext==0.7.0
vext.gi==0.6.8

But when I try to run an example, I get an error message that pyatspi is missing:

$ 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

I already have the python3-pyatspi package installed, but it obviously isn't accessible from within my virtualenv. "pyatspi" doesn't appear on PyPI, but I have found source code. How can I install pyatspi in my virtualenv?

like image 382
lofidevops Avatar asked Sep 11 '25 03:09

lofidevops


1 Answers

Since your package is not available on PyPI, you need to create you're virtualenv with the system packages (that includes your installed pyatspi):

$ virtualenv --system-site-packages foo
$ source foo/bin/activate

Another option is to include the pyatspi package "exclusively"

$ virtualenv --no-site-packages foo
$ source foo/bin/activate
$ ln -s /usr/lib/python3/dist-packages/pyatspi* $VIRTUAL_ENV/lib/python*/site-packages

The commands/paths might be slightly different depending on your environment. In order to find out the path to the pyatspi lib - start up the python shell (without an activated virtualenv), import the module and check module_name.path. e.g.

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']
like image 115
Tom Avatar answered Sep 13 '25 16:09

Tom