'Pyinstaller OSError: Cannot load AutoItX

I used import autoit. The script is running perfectly from VSCode and from Control Panel. But when making it an executable with PyInstaller, when I run the .exe file I get this error message:

enter image description here

pyinstaller --hidden-import=autoit --onefile run.py didn't work. How to bypass this problem?



Solution 1:[1]

1)Copy file(AutoItX3_x64.dll) from address

C:\Users\alire\AppData\Local\Programs\Python\Python39\Lib\site-packages\autoit\lib\
  1. Build folder(autoit\lib) in project and copy file there

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1