尝试将Win32ui与pywin32一起使用会给出:动态链接库(DLL)初始化例程失败 [英] Trying to use win32ui with pywin32 gives: A dynamic link library (DLL) initialization routine failed

查看:92
本文介绍了尝试将Win32ui与pywin32一起使用会给出:动态链接库(DLL)初始化例程失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用pywin32中的win32ui模块(是的,我具有正确的版本).我的win32gui模块确实可以正常工作,但是ui模块却给了我错误.我已经尝试过:重新安装python,还要添加PYTHON_PATH系统变量,运行安装后pywin32脚本,对于其余的事情,我有点力所能及.

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版本:3.9(64位)Pywin32版本:pywin32-228.win-amd64-py3.9(是.exe文件名,我不知道如何查找版本)只是为了清除我唯一的代码是:

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:

导入win32ui

(这是我的第一个问题,所以我希望我做对了)

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

推荐答案

更新

将(以下)修复程序(以及更多)应用于原始资源,进行构建,然后将 .whl 上传到 v228 发布以来已有 4 + 个月),我希望很快(在接下来的几天之内) v229 .

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 32bit (适用于旧版本)
  • PyWin32 228 (及更低版本)
  • 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

我为进行了一些调试(创建了 VStudio 2015 解决方案(包含2个项目:用于 Python 3.9 Python 3.8 )win32ui ),事实证明这是一个访问冲突( segfault ).
最佳"广告部分原因是发生在之前 DllMain .

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));

这是静态成员.由于2 nd 和3 rd 参数也是静态成员(没有注意它们是指针的事实),所以我认为它是 [ISOCPP]:什么是静态初始化顺序惨败"(问题)"?,然后我追了一些鬼.

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.

无论如何,今天我注意到 [GitHub]:mhammond/pywin32-导入在它所解决的Python 3.9上损坏的win32ui).

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

这篇关于尝试将Win32ui与pywin32一起使用会给出:动态链接库(DLL)初始化例程失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆