Bug Resolution: Multiple windows pop up when the PyQt5 program is packaged and executed
Bug Description
- Operating system: Windows 11
- IDE: PyCharm 2023.2
- Language: Python
![](/images/PyQt5-1/new_windows.png)
I used PyQt5 in Python to develop a GUI for a simple program. After the development was completed, I packaged the program to generate an exe file. But when I run this exe file and click the button on the GUI, a new window will pop up. If I click the button repeatedly, new windows keep being generated. This problem does not occur when debugging and running the program in PyCharm.
Solution
Add the following code in the main function:
1 | multiprocessing.freeze_support() |
The main function is as follows:
1 | if __name__ == '__main__': |