There is a working code that tracks keystrokes using the Pynput
library.
from pynput import keyboard
DEF ON_PRESS (Key):
Print ('Press', Key)
if __name__ == '__main__':
T = Keyboard.listener (On_press = On_press) .start ()
INPUT ('PRESS ENTER TO CLOSE PROGRAM')
If you collect it using Pyinstaller
, when you start, an error appears:
Windows 10, Python3.7.6, Pyinstaller 4.2
How can this be fixed?
Answer 1, Authority 100%
This problem is related to dynamic import .
pyinstaller does not know that PynPut is going to load something else.
Solution This:
c: \ cmd & gt; pyinstaller your_script.py --hidden-import "pynput.keyboard._win32" --hidden -Import "pynput.mouse._win32"