The program works fine including the win32gui calls but the executable gives this error
File "Client.py", line 1, in <module>
ImportError: DLL load failed while importing win32gui: Le module spécifié est introuvable.
[4628] Failed to execute script Client```
I am running on :
Win 10
Python 3.8
Problem was hidden imports
So if someone has the same problem you need to add the missing module when building the executable as follows:
pyinstaller pathToYourPythonFile/script.py --onefile --hidden-import theMissingModule
For my case the missing module was win32gui. After fixing it, it was another one: screenshot_every from d3dshot library
So basically you will face this problem if it was a sub import aka :
from d3dshot import screenshot_every
so screenshot_every is the hidden import ( you will need to do this to reduce the .exe size )