I am pretty new to raspberry and Linux. I am trying to run basic example of python library uinput on Raspbian (r Pi 3 B) with following code:
import uinput
device = uinput.Device([
uinput.BTN_LEFT,
uinput.BTN_RIGHT,
uinput.REL_X,
uinput.REL_Y,
])
for i in range(20):
device.emit(uinput.REL_X, 5)
device.emit(uinput.REL_Y, 5)
I get the error:
Traceback (most recent call last):
File "/home/pi/Desktop/t1.py", line 7, in uinput.REL_Y, File "/home/pi/.local/lib/python3.5/site-packages/uinput/init.py", line 178, in init self.uinput_fd = fd or fdopen() File "/home/pi/.local/lib/python3.5/site-packages/uinput/__init.py", line 84, in fdopen return _libsuinput.suinput_open() File "/home/pi/.local/lib/python3.5/site-packages/uinput/init.py", line 70, in _open_error_handler raise OSError(code, msg)
OSError: [Errno 19] Failed to open the uinput device: No such device What is wrong? What do I need to change and where?
Is the uinput
driver module loaded?
Try:
$ lsmod | grep uinput
Probably that will display nothing, which would mean that the driver is not loaded. Try loading it:
$ modprobe uinput
Then try your Python code. If you are not running your code with root privileges you will probably then get a PermissionError
due to the access permissions on the /dev/uinput
device file.