qentinelqi / qweb

Keyword driven automation for the web
https://github.com/qentinelqi/qweb
Apache License 2.0
40 stars 17 forks source link

QWeb library import fails on Ubuntu (20.04.5 LTS) due to Pynput #103

Closed jcsingh closed 2 years ago

jcsingh commented 2 years ago

Describe the bug Python (3.8.12) import of QWeb (2.0.4) fails on Ubuntu (20.04.5 LTS)

To Reproduce Steps to reproduce the behavior:

  1. On Ubuntu (20.04.5 LTS) open terminal and start python console
  2. Import QWeb
  3. See below error

[ WARN ] Cannot import pynput.keyboard, no display detected

  | [ ERROR ] Error in file '/workdir/resources/UICommon.resource' on line 2: Importing library 'QWeb' failed: ImportError: this platform is not supported: ('failed to acquire X connection: Bad display name ""', DisplayNameError(''))   |     | Try one of the following resolutions:   |     | * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly   | Traceback (most recent call last):   | File "/usr/local/lib/python3.8/site-packages/QWeb/init.py", line 26, in   | from QWeb.keywords import (alert, browser, window, frame, element, text, checkbox, input,   | File "/usr/local/lib/python3.8/site-packages/QWeb/keywords/text.py", line 27, in   | from pynput.keyboard import Controller   | File "/usr/local/lib/python3.8/site-packages/pynput/init.py", line 40, in   | from . import keyboard   | File "/usr/local/lib/python3.8/site-packages/pynput/keyboard/init.py", line 31, in   | backend = backend(name)   | File "/usr/local/lib/python3.8/site-packages/pynput/_util/init.py", line 76, in backend   | raise ImportError('this platform is not supported: {}'.format(   | PYTHONPATH:   | /workdir   | /usr/local/lib/python38.zip   | /usr/local/lib/python3.8   | /usr/local/lib/python3.8/lib-dynload   | /usr/local/lib/python3.8/site-packages

Expected behavior Python should be able to import QWeb module

Screenshots

Screen Shot 2022-10-14 at 8 04 10 PM

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context The exception is caused by Pynput module on Ubuntu

tkoukkari commented 2 years ago

hi, thanks for the bug report. We do have linux in our acceptance tests. They used to be run on Ubuntu 20.04 but currently it's using 22.04 already. In any case we have not seen this. Can you tell a bit more about your environment / configuration? The "no display detected" message is interesting and probably meaningful.

tkoukkari commented 2 years ago

X server needs to be running and it seems like it's not. If you look at our headless acceptance tests, you will find we do something like this for example:

DISPLAY: :88
...
sudo apt-get install matchbox scrot
Xvfb $DISPLAY -screen 0 1920x1080x24 & sleep 1
matchbox-window-manager -use_titlebar no &
jcsingh commented 2 years ago

Thanks @tkoukkari. Steps in your last comment fixed the issue for me.

tkoukkari commented 2 years ago

Thanks @tkoukkari. Steps in your last comment fixed the issue for me.

Great!

Tuomas