I am running the Debian lite cli PI 3 I have a wired USB mouse I have plugged into one of 4 usb ports I am trying to write a python script to detect when I left/right click and use the scroll wheel.
Core question : How do I detect mouse clicks on the raspberry pi with only the cli (I do not want the mouse to interact with the cli, just, for now, to print something to the console)
I have tried pynput but when running import pynput
I get the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python2.7/site-packages/pynput/__init__.py", line 40, in <module>
from . import keyboard
File "/home/pi/.local/lib/python2.7/site-packages/pynput/keyboard/__init__.py", line 31, in <module>
backend = backend(__name__)
File "/home/pi/.local/lib/python2.7/site-packages/pynput/_util/__init__.py", line 82, in backend
if resolutions else '')
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
--
1 Does this mean that pynput is not compatible with the rpi?
2 Or have I done something wrong?
3 Is pynput the thing to use? (I just need to detect the mouse)