gvalkov/python-evdev

Unknown Files

buntiken000 opened this issue · 4 comments

I'm trying to get evdev set up on a raspberry pi, and I've gotten it all set up, but when I run it to check that its all running, the ecodes.py file tries to call _ecodes from evdev. There is no file named _ecodes in any of the files, and I've redownloaded the files on a separate device to look them over, and I haven't found the file. Am I doing something wrong or is there a file missing? Or could I alter the code to get it to work as is?

Hi @buntiken000,

_ecodes is an extension module built from ecodes.c, which are generated when you install the package. You can see this in action when you install with pip install -v evdev:

...
running build_ext
  running build_ecodes
  writing /tmp/pip-install-t8vnsea9/evdev_..../evdev/ecodes.c (using /usr/include/linux/input.h /usr/include/linux/input-event-codes.h /usr/include/linux/uinput.h)
  ...
  building 'evdev._ecodes' extension
  ...
  copying build/lib.linux-x86_64-cpython-312/evdev/_ecodes.cpython-312-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/wheel/evdev

If you want to achieve the same thing from a clone of the project:

git clone git@github.com:gvalkov/python-evdev.git && cd python-evdev
pip install --editable .
python3 -c 'import evdev._ecodes; print(evdev._ecodes)
<module 'evdev._ecodes' from '/tmp/python-evdev/evdev/_ecodes.cpython-312-x86_64-linux-gnu.so'>

Make sure you have the kernel and python headers and a compiler installed on your raspberry pi (docs).

Is there a way I can get it without the pip install command? I can't connect my rasberry pi to wifi and hence can't do the downloads through it.

pip install .

in the cloned directory seems builds it for me even without wifi. Is it not building for you?

Other than that, you can also try

python3 setup.py build
sudo python3 setup.py install

Hey, I got it working, thank you for all the help and suggestions.