I installed evdev on my Raspberry Pi 3 B+ with sudo -H pip install evdev
.
The installation went normally and I ran python /usr/local/lib/python2.7/dist-packages/evdev/evtest.py
to see if it was working. Everything was fine.
The issue is that when executing this Python code:
from evdev import InputDevice, categorize, ecodes
gamepad = InputDevice('/dev/input/js0')
print(gamepad)
for event in gamepad.read_loop():
print(categorize(event)
I get this error as an answer:
Traceback (most recent call last):
File "evdev1.py", line 1, in <module>
from evdev import InputDevice, categorize, ecodes
File "/home/pi/Desktop/evdev.py", line 2, in <module>
from evdev import InputDevice, categorize, ecodes
ImportError: cannot import name 'InputDevice'
But when I execute from evdev import InputDevice, categorize, ecodes
on a python shell it seems to work.
What am I doing wrong? How can I solve this?
Thankfully, Davi.