question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to install pyautogui on Linux: Attribute error

See original GitHub issue

I am trying to install Pyautogui on Ubuntu using pip. I use python version 2.7.6. I have already installed xlib using apt-get install python-xlib. When I try pip install pyautogui, I run into the following error. Can someone please tell me what I could do about this.

Downloading/unpacking pyautogui
  Downloading PyAutoGUI-0.9.36.tar.gz (46kB): 46kB downloaded
  Running setup.py (path:/tmp/pip_build_phani/pyautogui/setup.py) egg_info for package pyautogui
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_phani/pyautogui/setup.py", line 6, in <module>
        version=__import__('pyautogui').__version__,
      File "pyautogui/__init__.py", line 115, in <module>
        from . import _pyautogui_x11 as platformModule
      File "pyautogui/_pyautogui_x11.py", line 160, in <module>
        _display = Display(os.environ['DISPLAY'])
      File "/usr/local/lib/python2.7/dist-packages/Xlib/display.py", line 127, in __init__
        mod.init(self, info)
      File "/usr/local/lib/python2.7/dist-packages/Xlib/ext/xinput.py", line 652, in init
        disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData)
      File "/usr/local/lib/python2.7/dist-packages/Xlib/display.py", line 227, in __getattr__
        raise AttributeError(attr)
    AttributeError: ge_add_event_data
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_phani/pyautogui/setup.py", line 6, in <module>

    version=__import__('pyautogui').__version__,

  File "pyautogui/__init__.py", line 115, in <module>

    from . import _pyautogui_x11 as platformModule

  File "pyautogui/_pyautogui_x11.py", line 160, in <module>

    _display = Display(os.environ['DISPLAY'])

  File "/usr/local/lib/python2.7/dist-packages/Xlib/display.py", line 127, in __init__

    mod.init(self, info)

  File "/usr/local/lib/python2.7/dist-packages/Xlib/ext/xinput.py", line 652, in init

    disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData)

  File "/usr/local/lib/python2.7/dist-packages/Xlib/display.py", line 227, in __getattr__

    raise AttributeError(attr)

AttributeError: ge_add_event_data

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_phani/pyautogui
Storing debug log for failure in /home/phani/.pip/pip.log

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
ad-mcommented, Jan 21, 2018

There is another issue in installation:

$ docker-compose build web
Building web
Step 1/7 : FROM python:3-slim
 ---> dc41c0491c65
Step 2/7 : ADD kadlubek/requirements.txt /code/requirements.txt
 ---> 39f4b8a3eea8
Step 3/7 : RUN pip install -r /code/requirements.txt
 ---> Running in a9a5135de791
Collecting selenium==3.8.1 (from -r /code/requirements.txt (line 1))
  Downloading selenium-3.8.1-py2.py3-none-any.whl (942kB)
Collecting python-xlib==0.21 (from -r /code/requirements.txt (line 2))
  Downloading python_xlib-0.21-py2.py3-none-any.whl (123kB)
Collecting pyautogui==0.9.36 (from -r /code/requirements.txt (line 3))
  Downloading PyAutoGUI-0.9.36.tar.gz (46kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-08vkzwl7/pyautogui/setup.py", line 6, in <module>
        version=__import__('pyautogui').__version__,
      File "/tmp/pip-build-08vkzwl7/pyautogui/pyautogui/__init__.py", line 115, in <module>
        from . import _pyautogui_x11 as platformModule
      File "/tmp/pip-build-08vkzwl7/pyautogui/pyautogui/_pyautogui_x11.py", line 7, in <module>
        from Xlib.display import Display
    ModuleNotFoundError: No module named 'Xlib'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-08vkzwl7/pyautogui/
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r /code/requirements.txt' returned a non-zero code: 1

In setup.py there is import to pyautogui. It fails due installation order.

0reactions
stardivinercommented, Aug 19, 2020

I have similar error:

Looking in indexes: https://mirrors.aliyun.com/pypi/simple
Collecting pyautogui
  Using cached https://mirrors.aliyun.com/pypi/packages/a3/69/c8b0cab7cbc6badbc0079392e5d4b50f3e4be63e0091f0f414bd1ea4ac07/PyAutoGUI-0.9.50.tar.gz (57 kB)
Collecting pymsgbox
  Using cached https://mirrors.aliyun.com/pypi/packages/e0/d5/148383b342b621a23cb340e7b378122d3fd53a631c5e5142a5c869bdfa5b/PyMsgBox-1.0.8.tar.gz (18 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /home/stardiviner/.virtualenvs/python3.8/bin/python /home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-4b7d6dko/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://mirrors.aliyun.com/pypi/simple -- 'setuptools>=40.8.0' wheel
       cwd: None
  Complete output (42 lines):
  Traceback (most recent call last):
    File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
      return _run_code(code, main_globals, None,
    File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
      exec(code, run_globals)
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/__main__.py", line 26, in <module>
      sys.exit(_main())
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
      command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
      module = importlib.import_module(module_path)
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
    File "<frozen importlib._bootstrap>", line 991, in _find_and_load
    File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 783, in exec_module
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 17, in <module>
      from pip._internal.cli.req_command import RequirementCommand, with_cleanup
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 16, in <module>
      from pip._internal.index.collector import LinkCollector
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 14, in <module>
      from pip._vendor import html5lib, requests
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_vendor/requests/__init__.py", line 125, in <module>
      from . import utils
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_vendor/requests/utils.py", line 25, in <module>
      from . import certs
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_vendor/requests/certs.py", line 15, in <module>
      from pip._vendor.certifi import where
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_vendor/certifi/__init__.py", line 1, in <module>
      from .core import contents, where
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip/_vendor/certifi/core.py", line 12, in <module>
      from importlib.resources import path as get_path, read_text
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/importlib/resources.py", line 11, in <module>
      from typing import Iterable, Iterator, Optional, Set, Union   # noqa: F401
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/typing.py", line 1347, in <module>
      class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
    File "/home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/typing.py", line 1003, in __new__
      self._abc_registry = extra._abc_registry
  AttributeError: type object 'Callable' has no attribute '_abc_registry'
  ----------------------------------------
ERROR: Command errored out with exit status 1: /home/stardiviner/.virtualenvs/python3.8/bin/python /home/stardiviner/.virtualenvs/python3.8/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-4b7d6dko/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://mirrors.aliyun.com/pypi/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to install PyAutoGui on Linux - Stack Overflow
I tried to install pyautogui on older python version, and have same error. I also tried to install all dependencies separately, and got...
Read more >
ModuleNotFoundError: No module named 'pyautogui' in Python
To solve the error, install the module by running the pip install pyautogui command. no module named pyautogui. Open your terminal in your ......
Read more >
20 controlling the keyboard and mouse with gui automation
When you run import pyautogui, Python will import your program instead of the PyAutoGUI and you'll get error messages like AttributeError: module 'pyautogui' ......
Read more >
Installation - PyAutoGUI documentation - Read the Docs
To install PyAutoGUI, install the pyautogui package from PyPI by running pip install pyautogui (on Windows) or pip3 install pyautogui (on macOS and...
Read more >
pip3 install pyautogui fails with error code 1 Mac OS
Similar question · Install Xcode from AppStore · activate virtual environment (if needed) · pip3 install pyobjc-core · pip3 install pyobjc-framework-Quartz · pip3 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found