The problem I'm having is that I can't add the PyNput module to my environment in Replit. I'm getting this error when I click "install":
warning: no previously-included files found matching '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
hint: This usually indicates a problem with the package or the build
environment.
help: `evdev` (v1.7.1) was included because `python-template` (v0.1.0)
depends on `pynput` (v1.7.7) which depends on `evdev`
exit status 1
I don't know how to fix this. I'm on Linux if that helps.
In your replit.nix
file, in the deps
list, add the following:
pkgs.python311Packages.pynput
Therefore, if you haven't added Nix packages before, you can copy and paste the full replit.nix
:
{pkgs}: {
deps = [
pkgs.python311Packages.pynput
];
}
You can then import pynput
normally.
The Replit environment will attempt to install the package using uv
. To not let Replit do this every time you run the repl, add the following line to the .replit
file, below the entrypoint
line:
disableGuessImports = true
Now, you should be able to run pynput
, and it will open in the Output tab when you run the repl.