After installing pywinauto I'm trying to run that simple code:
from pywinauto import Application
filename = 'notepad.exe'
app = aplication.Application().start(filename)
And get the error:
Traceback (most recent call last):
File "D:\auto\retr\test.py", line 1, in <module>
from pywinauto import Application
File "D:\Users\222\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\__init__.py", line 89, in <module>
from . import findwindows
File "D:\Users\222\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
from . import controls
File "D:\Users\222\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\controls\__init__.py", line 36, in <module>
from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
File "D:\Users\222\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\controls\uiawrapper.py", line 42, in <module>
from .. import backend
File "D:\Users\222\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\backend.py", line 35, in <module>
from .base_wrapper import BaseWrapper
File "D:\Users\222\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\base_wrapper.py", line 44, in <module>
import win32ui
ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed.
If I do import of win32ui explicitly:
import win32ui
from pywinauto import Application
The error got simpler, but still nothing to do with:
Traceback (most recent call last):
File "D:\auto\retr\test.py", line 1, in <module>
import win32ui
ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed.
I googled similar issues, but did not find any solution..
I have Win10, python 3.9
It would appear this is a duplicate of Trying to use win32ui with pywin32 gives: A dynamic link library (DLL) initialization routine failed
From the looks of that and the Github page, import win32ui
is actually broken on Python 3.9 using pywin32 build 228. There is a workaround posted in the other question. The short story is that build 229 is preferred, and until that release, the Github page has a workaround by manually installing a fork of the 228 build that is patched or a manual version of the 229 build.
For convenience, the .whls can be found here. Download the appropriate file and use:
pip install -U --force-reinstall <FILE>.whl
and the problem will most likely be fixed.