It seems it's a know bug in pynput due to naming conflicts. A fix was posted by a user. Here is the link: https:
//github.com/moses-palmer/pynput/tree/fixup/listener-thread-handle
List of committed changes:
[Rename _handle for xorg listener,
Rename _handle for uinput listener,
Rename _handle for win32 listener,
Rename _handle for darwin listener]