0

I used pip install evdev to install evdev in a conda env installed on Ubuntu. But it gives the following error.

 In file included from /nvme-ssd1/wuwenqiang/nvme-ssd1/wuwenqiang/envs/human_policy/include/python3.11/Python.h:91,
 from src/evdev/ecodes.c:1:
 src/evdev/ecodes.c: In function ‘PyInit__ecodes’:
 src/evdev/ecodes.c:542:29: error: ‘KEY_LINK_PHONE’ undeclared (first use in this function); did you mean ‘KEY_PICKUP_PHONE’?
 542 | PyModule_AddIntMacro(m, KEY_LINK_PHONE);
 | ^~~~~~~~~~~~~~
 /nvme-ssd1/wuwenqiang/nvme-ssd1/wuwenqiang/envs/human_policy/include/python3.11/modsupport.h:63:67: note: in definition of macro ‘PyModule_AddIntMacro’
 63 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
 | ^
 src/evdev/ecodes.c:542:29: note: each undeclared identifier is reported only once for each function it appears in
 542 | PyModule_AddIntMacro(m, KEY_LINK_PHONE);
 | ^~~~~~~~~~~~~~
 /nvme-ssd1/wuwenqiang/nvme-ssd1/wuwenqiang/envs/human_policy/include/python3.11/modsupport.h:63:67: note: in definition of macro ‘PyModule_AddIntMacro’
 63 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
 | ^
 src/evdev/ecodes.c:616:29: error: ‘KEY_REFRESH_RATE_TOGGLE’ undeclared (first use in this function)
 616 | PyModule_AddIntMacro(m, KEY_REFRESH_RATE_TOGGLE);
 | ^~~~~~~~~~~~~~~~~~~~~~~
 /nvme-ssd1/wuwenqiang/nvme-ssd1/wuwenqiang/envs/human_policy/include/python3.11/modsupport.h:63:67: note: in definition of macro ‘PyModule_AddIntMacro’
 63 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
 | ^
 src/evdev/ecodes.c:631:29: error: ‘KEY_ACCESSIBILITY’ undeclared (first use in this function)
 631 | PyModule_AddIntMacro(m, KEY_ACCESSIBILITY);
 | ^~~~~~~~~~~~~~~~~
 /nvme-ssd1/wuwenqiang/nvme-ssd1/wuwenqiang/envs/human_policy/include/python3.11/modsupport.h:63:67: note: in definition of macro ‘PyModule_AddIntMacro’
 63 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
 | ^
 src/evdev/ecodes.c:632:29: error: ‘KEY_DO_NOT_DISTURB’ undeclared (first use in this function)
 632 | PyModule_AddIntMacro(m, KEY_DO_NOT_DISTURB);
 | ^~~~~~~~~~~~~~~~~~
 /nvme-ssd1/wuwenqiang/nvme-ssd1/wuwenqiang/envs/human_policy/include/python3.11/modsupport.h:63:67: note: in definition of macro ‘PyModule_AddIntMacro’
 63 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
 | ^
 error: command '/usr/bin/gcc' failed with exit code 1
 [end of output]
 
 note: This error originates from a subprocess, and is likely not a problem with pip.
 ERROR: Failed building wheel for evdev
Failed to build evdev
error: failed-wheel-build-for-install×ばつ Failed to build installable wheels for some pyproject.toml based projects

I tried to add gcc to environment path but didn't work. And I checked the gcc path. It uses the system compiler. Is there anyone know how to solve it?

asked Aug 6, 2025 at 9:20
1

2 Answers 2

1

To avoid making changes in system files you can download package from PyPI. Then you are able to comment lines that causes error, and build package from file.

Steps to solve

  1. Open PyPI and download archive with package
  2. Extract folder from archive to any known place
  3. Open file src/evdev/ecodes.c
  4. Comment line 542
[...]
PyModule_AddIntMacro(m, KEY_PICKUP_PHONE);
PyModule_AddIntMacro(m, KEY_HANGUP_PHONE);
//PyModule_AddIntMacro(m, KEY_LINK_PHONE);
PyModule_AddIntMacro(m, KEY_DEL_EOL);
PyModule_AddIntMacro(m, KEY_DEL_EOS);
[...]
  1. Open terminal and activate your venv (if you are using it)
  2. Go to folder with given package and write
pip install .
  1. If there are more problematic lines in ecodes.c files, comment them like in step 4

Now your package evdev should be installed without any errors.

answered Aug 13, 2025 at 20:00
Sign up to request clarification or add additional context in comments.

Comments

0

Here are some fixes from the issue 166 on the evdev GitHub repository page.

1

brew unlink linux-headers

Which was mentioned by albertz.

2

export CC=/usr/bin/gcc
export CXX=/usr/bin/g++

Which was mentioned by syhanjin


The issue was replicated using Ubuntu22.04, Python3.10 (through conda)


Some options that probably won't work, but I mine as well put them here:

  1. Use a different ENV like pyenv
  2. Reinstall GCC / G++

Most likely won't do anything, but you never know


It does seem like the issue is mostly on Ubuntu, since users on other platforms seem to say it works fine.


PS - jabaa pointed out issue #166 in their comment on this post, I just wanted to put the info here.


EDIT

I made this while really tired, so I'm sorry if I messed some stuff up here.

answered Sep 25, 2025 at 8:56

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.