Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip3 install pyautogui, error code 1

I can't install pyautogui i've tried everything, such as

pip3 install pillow

also followed the steps on the website pyautogui website. Here is the message i receive when installing.

root@alex-Ai:/# pip3 install pyautogui
Collecting pyautogui
Using cached PyAutoGUI-0.9.36.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/Xlib/xauth.py", line 42, in __init__
    raw = open(filename, 'rb').read()
FileNotFoundError: [Errno 2] No such file or directory: '/root/.Xauthority'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-mvyjt7lg/pyautogui/setup.py", line 6, in <module>
    version=__import__('pyautogui').__version__,
  File "/tmp/pip-build-mvyjt7lg/pyautogui/pyautogui/__init__.py", line 115, in <module>
    from . import _pyautogui_x11 as platformModule
  File "/tmp/pip-build-mvyjt7lg/pyautogui/pyautogui/_pyautogui_x11.py", line 160, in <module>
    _display = Display(os.environ['DISPLAY'])
  File "/usr/lib/python3/dist-packages/Xlib/display.py", line 80, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python3/dist-packages/Xlib/display.py", line 62, in __init__
    display.Display.__init__(*(self, ) + args, **keys)
  File "/usr/lib/python3/dist-packages/Xlib/protocol/display.py", line 61, in __init__
    name, host, displayno)
  File "/usr/lib/python3/dist-packages/Xlib/support/connect.py", line 93, in get_auth
    return getattr(mod, modname).get_auth(sock, dname, host, dno)
  File "/usr/lib/python3/dist-packages/Xlib/support/unix_connect.py", line 116, in new_get_auth
    au = xauth.Xauthority()
  File "/usr/lib/python3/dist-packages/Xlib/xauth.py", line 44, in __init__
    raise error.XauthError('~/.Xauthority: %s' % err)
Xlib.error.XauthError: ~/.Xauthority: [Errno 2] No such file or directory: '/root/.Xauthority'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mvyjt7lg/pyautogui/

@phd "sudo -H pip3 install pyautogui " gives me this error

      alex@aimarket:/home$ sudo -H pip3 install pyautogui
      Collecting pyautogui
      Using cached PyAutoGUI-0.9.36.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-efkrhbdk/pyautogui/setup.py", line 6, in <module>
    version=__import__('pyautogui').__version__,
  File "/tmp/pip-build-efkrhbdk/pyautogui/pyautogui/__init__.py", line 115, in <module>
    from . import _pyautogui_x11 as platformModule
  File "/tmp/pip-build-efkrhbdk/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-efkrhbdk/pyautogui/
like image 810
Alex Torres Avatar asked Jun 07 '26 01:06

Alex Torres


2 Answers

pip install python-xlib

worked for me.

like image 76
markroxor Avatar answered Jun 09 '26 14:06

markroxor


I used pyvirtualdisplay and pyautogui and got the same error when I tried to package this to docker.
The use_xauth = True parameter helped me when creating the display.

display = Display(visible=False, size=(800, 600), use_xauth=True)

Don't forget to install xauth as well

sudo apt-get install xauth
like image 33
Alexander Goryushkin Avatar answered Jun 09 '26 15:06

Alexander Goryushkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!