'Hiding console using --noconsole command but encountering error

I made and exe file using pyinstaller and when I m trying to hide the console using --noconsole or -w then this command runs perfectly pyinstaller --onefile --noconsole main.py But after running the .exe file a error dialog appears with title Fatal error! With message main.exe returned -1



Sources

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

Source: Stack Overflow

Solution Source