Home python pyinstaller can't assemble the program

pyinstaller can’t assemble the program

Author

Date

Category

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"

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions