0

Tengo un entorno virtual creado con virtualenv con la versión de python 3.9 donde estoy haciendo pruebas de desarrollo; sin embargo, el resultado que obtengo es el siguiente:


**❯ pip install pynput
Collecting pynput
  Using cached pynput-1.7.6-py2.py3-none-any.whl (89 kB)
Collecting python-xlib>=0.17
  Using cached python_xlib-0.33-py2.py3-none-any.whl (182 kB)
Collecting evdev>=1.3
  Using cached evdev-1.6.0.tar.gz (26 kB)
  Preparing metadata (setup.py) ... done
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Building wheels for collected packages: evdev
  Building wheel for evdev (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [69 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-39
      creating build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/events.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/genecodes.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/ecodes.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/uinput.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/eventio_async.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/evtest.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/__init__.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/ff.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/eventio.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/device.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/util.py -> build/lib.linux-x86_64-cpython-39/evdev
      running build_ext
      running build_ecodes
      writing ecodes.c (using /usr/include/linux/input.h /usr/include/linux/input-event-codes.h /usr/include/linux/uinput.h)
      /bin/sh: 1: /home/cesar_chavez/Documentos/Python/Entorno: not found
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-1no4xpgj/evdev_8e936150e2984745a1b81503b8e8e491/setup.py", line 151, in <module>
          setup(**kw)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
          super().run_command(command)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 325, in run
          self.run_command("build")
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
          super().run_command(command)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
          super().run_command(command)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-install-1no4xpgj/evdev_8e936150e2984745a1b81503b8e8e491/setup.py", line 138, in run
          self.run_command(cmd_name)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
          super().run_command(command)
        File "/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-install-1no4xpgj/evdev_8e936150e2984745a1b81503b8e8e491/setup.py", line 125, in run
          create_ecodes(self.evdev_headers)
        File "/tmp/pip-install-1no4xpgj/evdev_8e936150e2984745a1b81503b8e8e491/setup.py", line 106, in create_ecodes
          check_call(cmd, cwd="%s/evdev" % here, shell=True)
        File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/bin/python genecodes.py /usr/include/linux/input.h /usr/include/linux/input-event-codes.h /usr/include/linux/uinput.h > ecodes.c' returned non-zero exit status 127.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for evdev
  Running setup.py clean for evdev
Failed to build evdev
Installing collected packages: evdev, six, python-xlib, pynput
  Running setup.py install for evdev ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for evdev did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      running install
      /home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-39
      creating build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/events.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/genecodes.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/ecodes.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/uinput.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/eventio_async.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/evtest.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/__init__.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/ff.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/eventio.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/device.py -> build/lib.linux-x86_64-cpython-39/evdev
      copying evdev/util.py -> build/lib.linux-x86_64-cpython-39/evdev
      running build_ext
      ecodes.c already exists ... skipping build_ecodes
      building 'evdev._input' extension
      creating build/temp.linux-x86_64-cpython-39
      creating build/temp.linux-x86_64-cpython-39/evdev
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC "-I/home/cesar_chavez/Documentos/Python/Entorno Virtual/wakeword/include" -I/usr/include/python3.9 -c evdev/input.c -o build/temp.linux-x86_64-cpython-39/evdev/input.o -std=c99 -Wno-error=declaration-after-statement
      evdev/input.c:10:10: fatal error: Python.h: No existe el archivo o el directorio
       #include <Python.h>
                ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-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: legacy-install-failure

× Encountered error while trying to install package.
╰─> evdev

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.**

Sé que es un tema de compilación por gcc debido a los archivos escritos en c++ pero tengo todas los paquetes necesarios, de hecho me apoyé en esta guía que comparto con ustedes por medio de este enlace. Todos los paquetes, wheel, pip setuptools están instalados y actualizados.

¿Alguien ha tenido un problema similar? Y de ser así, ¿cómo fue resuelto?

4
  • Tu problema es que no encuentra el directorio home/cesar_chavez/Documentos/Python/Entorno. Quizá porque es "/home/cesar_chavez/Documentos/Python/Entorno Virtual". Ese espacio es el problema. Quizá no has encerrado entre comillas. Commented el 5 ene. 2023 a las 4:47
  • Nop, tristemente no funciono tampoco en una carpeta nueva el entorno virtual en donde el nombre de dicha carpeta no tenía espacios, se aceptan nuevas sugerencias, mil gracias de antemano. Commented el 10 ene. 2023 a las 5:52
  • Parece que al generador de código que tiene que crear ecodes.c no le sienta muy bien ese espacio que has puesto en el directorio de los entornos ("Entorno Virtual"). Commented el 10 ene. 2023 a las 14:32
  • En el entorno nuevo sin espacio en el nombre ¿dio el mismo error? Commented el 10 ene. 2023 a las 18:22

1 respuesta 1

0

Después de tanto buscar encontré la solución a este dilema.

Básicamente sucede porque es necesario instalar las utilidades de desarrollo de la versión de Python que estás usando en tu proyecto en el entorno virtual creado. En mi caso, mi proyecto originalmente lo comencé a desarrollar en Python versión 3.9 y tuve que hacer algunos cambios para Python 3.10; el caso es que para solucionar el problema de instalación del módulo pynput usando pip fue necesario instalar paquetes adicionales de la versión de Python en cuestión. Sugiero, si te encuentras con este problema, apliques el siguiente comando desde la terminal fuera de tu entorno virtual creado:

sudo apt-get install python(version)-dev

Donde (version) puede ser 3.9, 3.10, etc.

1
  • No olvides aceptar tu respuesta.
    – padaleiana
    Commented el 10 ene. 2023 a las 10:19

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.