Getting error when using pynput with pyinstaller

Solution 1:

Please fall back to 1.6.8 version of pynput. pip install pynput==1.6.8

Solution 2:

If you are running Windows you need to add these parameters to the command line (for the first time, after that they will be included in the generated spec file).

--hidden-import "pynput.keyboard._win32" --hidden-import "pynput.mouse._win32"

For Linux, use:

--hidden-import "pynput.keyboard._xorg" --hidden-import "pynput.mouse._xorg"

More information can be found in this Github issue.