pynput icon indicating copy to clipboard operation
pynput copied to clipboard

How to install on Ubuntu? (uv)

Open FredrikNoren opened this issue 7 months ago • 1 comments

Description I'm trying to install this with uv add pynput but I'm getting an error. I can't find any information in the docs about how to install this?

Platform and pynput version pynput

fredrik@ml-fredrik-n4-standard-16-0:~/testy$ uname -a
Linux ml-fredrik-n4-standard-16-0.c.medal-2995f.internal 6.11.0-1015-gcp #15~24.04.1-Ubuntu SMP Thu Apr 24 20:41:05 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

To Reproduce Minimal repo:

fredrik@ml-fredrik-n4-standard-16-0:~/testy$ uv init
Initialized project `testy`
fredrik@ml-fredrik-n4-standard-16-0:~/testy$ uv add pynput
Using CPython 3.12.3 interpreter at: /usr/bin/python3.12
Creating virtual environment at: .venv
Resolved 10 packages in 188ms
  × Failed to build `evdev==1.9.2`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit status: 1)

      [stdout]
      running bdist_wheel
      running build
      running build_py
      copying src/evdev/eventio.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/eventio_async.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/__init__.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/evtest.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/genecodes_py.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/genecodes_c.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/uinput.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/ff.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/ecodes.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/ecodes_runtime.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/util.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/events.py -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/device.py -> build/lib.linux-x86_64-cpython-312/evdev
      running egg_info
      writing src/evdev.egg-info/PKG-INFO
      writing dependency_links to src/evdev.egg-info/dependency_links.txt
      writing top-level names to src/evdev.egg-info/top_level.txt
      reading manifest file 'src/evdev.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE'
      writing manifest file 'src/evdev.egg-info/SOURCES.txt'
      copying src/evdev/input.c -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/py.typed -> build/lib.linux-x86_64-cpython-312/evdev
      copying src/evdev/uinput.c -> build/lib.linux-x86_64-cpython-312/evdev
      running build_ext
      running build_ecodes

      [stderr]
      /home/fredrik/.cache/uv/builds-v0/.tmp4kHMJn/lib/python3.12/site-packages/setuptools/config/_apply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated
      !!

              ********************************************************************************
              Please use a simple string containing a SPDX expression for `project.license`. You can also use `project.license-files`. (Both options available on setuptools>=77.0.0).

              By 2026-Feb-18, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        corresp(dist, value, root_dir)
      /home/fredrik/.cache/uv/builds-v0/.tmp4kHMJn/lib/python3.12/site-packages/setuptools/config/_apply_pyprojecttoml.py:61: SetuptoolsDeprecationWarning: License classifiers are deprecated.
      !!

              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:

              License :: OSI Approved :: BSD License

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        dist._finalize_license_expression()
      /home/fredrik/.cache/uv/builds-v0/.tmp4kHMJn/lib/python3.12/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.
      !!

              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:

              License :: OSI Approved :: BSD License

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        self._finalize_license_expression()
      warning: no previously-included files found matching 'src/evdev/ecodes.c'
      The 'linux/input.h' and 'linux/input-event-codes.h' include files
      are missing. You will have to install the kernel header files in
      order to continue:

          dnf install kernel-headers-$(uname -r)
          apt-get install linux-headers-$(uname -r)
          emerge sys-kernel/linux-headers
          pacman -S kernel-headers

      In case they are installed in a non-standard location, you may use
      the '--evdev-headers' option to specify one or more colon-separated
      paths. For example:

          python setup.py \
            build \
            build_ecodes --evdev-headers path/input.h:path/input-event-codes.h \
            build_ext --include-dirs path/ \
            install

      If you want to avoid building this package from source, then please consider
      installing the `evdev-binary` package instead. Keep in mind that it may not be
      fully compatible with, or support all the features of your current kernel.

      hint: This usually indicates a problem with the package or the build environment.
  help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to skip locking and syncing.

FredrikNoren avatar May 28 '25 12:05 FredrikNoren

Came here looking for an answer to the same question as it failed on pip install evdev.

The thing that fixed it for me was using sudo apt install gcc python3-dev.

huntfx avatar Jun 02 '25 11:06 huntfx

Thank you for your report, and sorry for this late response.

I am in the process of updating the documentation, and this is one of the things that I am attempting to fix,

moses-palmer avatar Aug 12 '25 18:08 moses-palmer