pywinauto crashes with tkinter on Python 3.7 on exit
See original GitHub issueSimply importing pywinauto and tkinter together will crash Python 3.7 post execution
Expected Behavior
Not get any “Python has stopped working” crash message after Python script has executed.
Actual Behavior
After execution, Python should be able to exit gracefully without a crash message.
Steps to Reproduce the Problem
- import tkinter
 - import pywinauto
 - create a 
Tk()instance - quit 
Tkinstance - Python script will exit but a crash message will be shown
 
Short Example of Code to Demonstrate the Problem
import tkinter as tk
import pywinauto as pyw
root = tk.Tk()
Specifications
- Pywinauto version: 0.6.7
 - Python version and bitness: 3.7-32
 - Platform and OS: Windows 10 64 bit
 
Issue Analytics
- State:
 - Created 4 years ago
 - Reactions:1
 - Comments:9 (4 by maintainers)
 
Top Results From Across the Web
Combining Tkinter and win32ui makes Python crash on exit
A workaround is to invoke the Tkinter-win32UI app with pythonw. Python doesn't crash. Tested with Python 3.6.3 on Win 10.
Read more >Python Has Stopped Working When Importing Pywinauto ...
Hi I've logged this in the Python issue tracker already but I've been told pywinauto crashes with tkinter on Python 3.7 on exit...
Read more >List of issues - Python tracker
Severity ID GH Creation Activ...
2018‑06‑29.15:48:52 duplicate 2018‑06‑29.15:48:52 duplicate
normal 34000 78181 53 months ago 7 mo...
2018‑06‑29.16:09:13 fixed 2018‑06‑29.16:09:13 fixed
Read more >Pygame window wont move or close after using tkinter
How to close a window using pywinauto which does not have "File->exit" in menu? ... How to open and close another window with...
Read more >PyInstaller Documentation - Read the Docs
PyInstaller supports Python 3.7 and newer, and correctly ... The _MEIxxxxxx folder is not removed if the program crashes or is killed (kill...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just wanted to add some additional information. In my case, I have Python 3.7.6 on Windows 10 and I was experiencing the same issue. The workaround of launching the script with pythonw did not work. The only workaround I found was using a hard exit after mainloop:
I tried to reproduce the problem with the abovementioned
but was unable to get any errors. I tested even with the same exact Python version, and tried multiple pywin32 versions. Tested versions, without any error:
This is strange since before at least with Python 3.7.7 32-bit + pywin 222-227 (some of them) I last time could reproduce the error. Also this did not produce the error (Python 3.7.7 32-bit + pywin 227 + pywinauto 0.6.8):
Some hypothesis for the reason:
(1) The pywin
pywin32_postinstall.pyhad one error on-remove: (Failed to unregister Pythonwin: [WinError 5] Access is denied), even with admin rights, but the-installand dll copying was working without errors. This could in theory affect testing of multiple pywin32 versions, but I think that’s very small change. (2) I have now new laptop and probably also newer Windows 10 build. (1909, OS Build 18363.1139). Maybe that could affect?Maybe there could be some other reasons, too, but seems that this will be difficult to hunt down. This as a note if anyone starts debugging the issue some day.