[Python] pip failied to build evdev

Discussão em 'Python' iniciado por Stack, Agosto 6, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página