3

I frequently get this error (9/10 times) when running my scripts that use pywinauto

File "C:\Anaconda3\envs\python3.4.5\lib\site-packages\pywinauto\base_wrapper.py", line 45, in <module>
    import win32ui
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.5\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

Sometimes there's no error but most of the times it errors out and so its taking me longer to test my scripts.

import win32ui on its own does not give any errors at all. Does anyone know how to get this resolved?

Python 3.4.5 Windows10 PyCharm Community Edition 2018.3.5

kronosjt
  • 703
  • 4
  • 10
  • 24
  • 1
    I suspect that you have both 32-bit and 64-bit installations of Python and it works when you load `pywinauto` from the Python of one bitness but not the other. You have to install *all* modules with C extensions (.pyd files) with bitness that matches the Python interpreter. – BoarGules Mar 26 '19 at 09:55
  • I've tried importing it in the same Pycharm project where it fails when being imported via pywinauto, so I can rule out bitness of Python here. – kronosjt Mar 27 '19 at 04:30
  • This looks like there is something that PyCharm's import wrapper is not handling as expected. Two things to try: (1) If you have imports of the form `import a,b,c` for modules that have anything to do with PythonWin then put the imports in separate statements. (2) Try putting `import win32ui` ahead of `import pywinauto` in your code. If the first import is successful then PyCharm's wrapper should do nothing and with any luck will then not fail. If that doesn't help I suggest you seek help on a JetBrains forum since the problem seems to be specifically related the PyCharm import hook manager. – BoarGules Mar 27 '19 at 09:16

0 Answers0