Trying to use win32ui with pywin32 gives: A dynamic link library (DLL) initialization routine failed

tovernaar123

I am trying to use the win32ui module from pywin32 (yes i have the correct version). My win32gui module does work fine but the ui module give me and error. I have already tried: reinstalling python, adding PYTHON_PATH too system vars, running the after install pywin32 script, For the rest I am kinda of out thing i can try to do.

Python version: 3.9 (64 bit) Pywin32 version: pywin32-228.win-amd64-py3.9 (is the .exe file name i don't know how to find the version) just to clear up my only code is:

import win32ui

(this is my first question so i hope i have done this right)

CristiFati

Update

Applied the (below) fix (and a couple of more) to the original sources, built them, and uploaded the .whls to [GitHub]: CristiFati/Prebuilt-Binaries - (master) Prebuilt-Binaries/PyWin32/v228.
But, since this bug is kind of a "deal breaker" (and there are 4+ months since v228 was released), I'm expecting v229 very soon (in the next days or so).

Check the Install steps section from (the beginning of) [SO]: PyWin32 and Python 3.8.0 (@CristiFati's answer) for details on how to install the .whls.



It's constantly reproducible on:

  • Python 3.9 64bit and 32bit (works on older versions)
  • PyWin32 228 (and older)
[cfati@CFATI-5510-0:e:\Work\Dev\GitHub\CristiFati\pywin32\src]> sopr.bat
*** Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ***

[prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.09.00_test0\Scripts\python.exe"
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32ui
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\Install\pc064\Python\Python\03.09.00\Lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed
>>> import win32api

I did some debugging (created a VStudio 2015 solution (with 2 projects: for Python 3.9 and Python 3.8) for win32ui), and it turns out it's an Access Violation (segfault).
The "best" part is that it's occurring before DllMain.

One of the last lines that I could get the debugger in, was [GitHub]: mhammond/pywin32 - (b228) pywin32/Pythonwin/win32RichEdit.cpp#225:

PyCCtrlView_Type PyCRichEditView::type("PyCRichEditView", &PyCCtrlView::type, &PyCRichEditCtrl::type,
                                       RUNTIME_CLASS(CRichEditView), sizeof(PyCRichEditView),
                                       PYOBJ_OFFSET(PyCRichEditView), PyCRichEditView_methods,
                                       GET_PY_CTOR(PyCRichEditView));

This is a static member. Since the 2nd and 3rd arguments are also static members (wasn't paying attention to the fact that they're pointers), I thought it was [ISOCPP]: What’s the “static initialization order ‘fiasco’ (problem)”?, and I chased some ghosts.

Anyway, today I noticed [GitHub]: mhammond/pywin32 - Ensure we hold the GIL as win32ui initializes and calls back into Python (and from there [GitHub]: mhammond/pywin32 - Import win32ui broken on Python 3.9 that it's addressing).

Applying the patch, fixes the problem:

[prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.09.00_test0\Scripts\python.exe"
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32ui
>>> import win32api

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Python

Cannot import from pywinauto: ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed

From Javascript

Electron Uncaught Error: A dynamic link library (DLL) initialization routine failed

From Dev

C#: A dynamic link library (DLL) initialization routine failed

From Dev

Tensorflow : DLL load failed: A dynamic link library (DLL) initialization routine failed

From Dev

FMUException: Error loading the binary. Could not load the DLL: A dynamic link library (DLL) initialization routine failed

From Dev

Electron running SQLlite 3 on Windows - A dynamic link library (DLL) initialization routine failed

From

Calling Golang from Java using JNI on Windows leads to "A dynamic link library (DLL) initialization routine failed"

From Dev

How to fix Java 15 JNI "UnsatisfiedLinkError: A dynamic link library (DLL) initialization routine failed"

From Dev

A dynamic link library (DLL) initialization routine failed | nw.js error connecting canvas

From Dev

Error while importing Tensorflow. A dynamic link library (DLL) initialization routine failed

From Dev

How to link a dynamic library in QtCreator use qmake and MinGW32?

From Dev

Writing to Windows Event Log using win32evtlog from pywin32 library

From Dev

Use pywin32 to go to specified page in word doc

From Dev

How to use PyWin32 to return Excel row?

From Dev

GetGUIThreadInfo() with pywin32

From Dev

Not able to use the win32gui module from pywin32 in Pycharm

From Dev

Build tesseract as DLL Dynamic link library

From Dev

Sorting with xlwings (pywin32)

From Dev

PyWin32 and Python 3.8.0

From Python

Failed Google App Engine deployment. No matching distribution found for pywin32==xxx

From Dev

Unable to load dynamic library php_sqlsrv_7_nts.dll is not a valid Win32 application

From Dev

Server library could not be loaded and the dynamic link library LIBPQ.dll

From Dev

How to use dynamic link library with CMake?

From Dev

Could not be located in dynamic link library php4ts.dll

From Dev

The ordinal 3283 could not be located in the dynamic link library libmysql.dll

From Dev

Compaq Visual Fortran 6.6, Dynamic-Link Library (DLL) and Module

From Dev

What is difference between win32com and pywin32?

From Dev

ImportError: No module named pywin32

From Dev

Getting this error using pywin32 module?

Related Related

  1. 1

    Cannot import from pywinauto: ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed

  2. 2

    Electron Uncaught Error: A dynamic link library (DLL) initialization routine failed

  3. 3

    C#: A dynamic link library (DLL) initialization routine failed

  4. 4

    Tensorflow : DLL load failed: A dynamic link library (DLL) initialization routine failed

  5. 5

    FMUException: Error loading the binary. Could not load the DLL: A dynamic link library (DLL) initialization routine failed

  6. 6

    Electron running SQLlite 3 on Windows - A dynamic link library (DLL) initialization routine failed

  7. 7

    Calling Golang from Java using JNI on Windows leads to "A dynamic link library (DLL) initialization routine failed"

  8. 8

    How to fix Java 15 JNI "UnsatisfiedLinkError: A dynamic link library (DLL) initialization routine failed"

  9. 9

    A dynamic link library (DLL) initialization routine failed | nw.js error connecting canvas

  10. 10

    Error while importing Tensorflow. A dynamic link library (DLL) initialization routine failed

  11. 11

    How to link a dynamic library in QtCreator use qmake and MinGW32?

  12. 12

    Writing to Windows Event Log using win32evtlog from pywin32 library

  13. 13

    Use pywin32 to go to specified page in word doc

  14. 14

    How to use PyWin32 to return Excel row?

  15. 15

    GetGUIThreadInfo() with pywin32

  16. 16

    Not able to use the win32gui module from pywin32 in Pycharm

  17. 17

    Build tesseract as DLL Dynamic link library

  18. 18

    Sorting with xlwings (pywin32)

  19. 19

    PyWin32 and Python 3.8.0

  20. 20

    Failed Google App Engine deployment. No matching distribution found for pywin32==xxx

  21. 21

    Unable to load dynamic library php_sqlsrv_7_nts.dll is not a valid Win32 application

  22. 22

    Server library could not be loaded and the dynamic link library LIBPQ.dll

  23. 23

    How to use dynamic link library with CMake?

  24. 24

    Could not be located in dynamic link library php4ts.dll

  25. 25

    The ordinal 3283 could not be located in the dynamic link library libmysql.dll

  26. 26

    Compaq Visual Fortran 6.6, Dynamic-Link Library (DLL) and Module

  27. 27

    What is difference between win32com and pywin32?

  28. 28

    ImportError: No module named pywin32

  29. 29

    Getting this error using pywin32 module?

HotTag

Archive