You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
comtypes.client.GetModule("UIAutomationCore.dll") failed in python 3.7.6 #202
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 18 2019, 23:46:00) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import comtypes
import comtypes.client
comtypes.client.GetModule("UIAutomationCore.dll")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "D:\Python37\lib\site-packages\comtypes\client_generate.py", line 110, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "D:\Python37\lib\site-packages\comtypes\client_generate.py", line 184, in _CreateWrapper
mod = _my_import(fullname)
File "D:\Python37\lib\site-packages\comtypes\client_generate.py", line 24, in my_import
return import(fullname, globals(), locals(), ['DUMMY'])
File "D:\Python37\lib\site-packages\comtypes\gen_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py", line 1244, in
( ['out', 'retval'], POINTER(POINTER(IUIAutomationElement)), 'element' )),
File "D:\Python37\lib\site-packages\comtypes_init.py", line 329, in setattr
self.make_methods(value)
File "D:\Python37\lib\site-packages\comtypes_init.py", line 698, in make_methods
prototype = WINFUNCTYPE(restype, *argtypes)
File "D:\Python37\lib\ctypes_init.py", line 123, in WINFUNCTYPE
class WinFunctionType(_CFuncPtr):
TypeError: item 2 in argtypes passes a union by value, which is unsupported.
This is wrong fix in Python 3.7.6 and 3.8.1. This is already reverted in Python (3.8.2rc1 is in validation now, so there is a hope to release Python 3.8.2 where it should work). Now just install earlier Python version.
The core of the problem is a missing feature in libffi (this is calling convention handling library used by ctypes for Python/C integration). But this feature is unlikely to be implemented soon.
I also have the problem:
when I execute .py, everything works well, but I use pyinstaller(3.6) build to exe, and run exe on another system that has no python environment, error occured. my python version 3.7.2
Traceback (most recent call last):
File "run.py", line 73, in main
File "Test_Suite\multiple_display_wes.py", line 99, in start
File "Common\vdi_connection.py", line 79, in wrapper
File "Common\vdi_connection.py", line 657, in logon
File "Common\vdi_connection.py", line 641, in close_citrix
File "site-packages\uiautomation\uiautomation.py", line 5860, in Exists
File "site-packages\uiautomation\uiautomation.py", line 7683, in FindControl
File "site-packages\uiautomation\uiautomation.py", line 7465, in GetRootControl
File "site-packages\uiautomation\uiautomation.py", line 51, in instance
File "site-packages\uiautomation\uiautomation.py", line 56, in init
File "site-packages\comtypes\client_generate.py", line 110, in GetModule
File "site-packages\comtypes\client_generate.py", line 172, in _CreateWrapper
File "site-packages\comtypes\tools\tlbparser.py", line 750, in generate_module
File "site-packages\comtypes\tools\codegenerator.py", line 241, in generate_code
File "site-packages\comtypes\tools\codegenerator.py", line 189, in generate_all
File "site-packages\comtypes\tools\codegenerator.py", line 185, in generate
File "site-packages\comtypes\tools\codegenerator.py", line 701, in ComInterface
File "site-packages\comtypes\tools\codegenerator.py", line 185, in generate
File "site-packages\comtypes\tools\codegenerator.py", line 722, in ComInterfaceHead
File "site-packages\comtypes\tools\codegenerator.py", line 185, in generate
File "site-packages\comtypes\tools\codegenerator.py", line 722, in ComInterfaceHead
File "site-packages\comtypes\tools\codegenerator.py", line 185, in generate
File "site-packages\comtypes\tools\codegenerator.py", line 629, in External
File "site-packages\comtypes\client_generate.py", line 110, in GetModule
File "site-packages\comtypes\client_generate.py", line 184, in _CreateWrapper
File "site-packages\comtypes\client_generate.py", line 24, in _my_import
ModuleNotFoundError: No module named 'comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0'
Hi @Wang-zhipeng this is completely different problem. First you need to know that comtypes generates Python code for UIAutomationCore.dll on the fly and saves it to cached .py file which is missing in your case (_00020430_0000_0000_C000_000000000046_0_2_0.py). The file name contains GUID of the COM library. You need some trick with PyInstaller to include this cached file into your executable.
I use pyinstaller build to exe, and run exe on another system that has no python environment, it can't run. my python version 3.9.4,UIAutomation version 2.0.15
The reverting change was committed on Jan 12, 2020. Python versions 3.7.7 (released Mar 10, 2020) and 3.8.2 (released Feb 24, 2020) should have the reversion.
Activity
vasily-v-ryabov commentedon Feb 13, 2020
This is wrong fix in Python 3.7.6 and 3.8.1. This is already reverted in Python (3.8.2rc1 is in validation now, so there is a hope to release Python 3.8.2 where it should work). Now just install earlier Python version.
The core of the problem is a missing feature in libffi (this is calling convention handling library used by ctypes for Python/C integration). But this feature is unlikely to be implemented soon.
yinkaisheng commentedon Feb 14, 2020
Thanks.
Wang-zhipeng commentedon Jul 13, 2020
I also have the problem:
when I execute .py, everything works well, but I use pyinstaller(3.6) build to exe, and run exe on another system that has no python environment, error occured. my python version 3.7.2
Traceback (most recent call last):
File "run.py", line 73, in main
File "Test_Suite\multiple_display_wes.py", line 99, in start
File "Common\vdi_connection.py", line 79, in wrapper
File "Common\vdi_connection.py", line 657, in logon
File "Common\vdi_connection.py", line 641, in close_citrix
File "site-packages\uiautomation\uiautomation.py", line 5860, in Exists
File "site-packages\uiautomation\uiautomation.py", line 7683, in FindControl
File "site-packages\uiautomation\uiautomation.py", line 7465, in GetRootControl
File "site-packages\uiautomation\uiautomation.py", line 51, in instance
File "site-packages\uiautomation\uiautomation.py", line 56, in init
File "site-packages\comtypes\client_generate.py", line 110, in GetModule
File "site-packages\comtypes\client_generate.py", line 172, in _CreateWrapper
File "site-packages\comtypes\tools\tlbparser.py", line 750, in generate_module
File "site-packages\comtypes\tools\codegenerator.py", line 241, in generate_code
File "site-packages\comtypes\tools\codegenerator.py", line 189, in generate_all
File "site-packages\comtypes\tools\codegenerator.py", line 185, in generate
File "site-packages\comtypes\tools\codegenerator.py", line 701, in ComInterface
File "site-packages\comtypes\tools\codegenerator.py", line 185, in generate
File "site-packages\comtypes\tools\codegenerator.py", line 722, in ComInterfaceHead
File "site-packages\comtypes\tools\codegenerator.py", line 185, in generate
File "site-packages\comtypes\tools\codegenerator.py", line 722, in ComInterfaceHead
File "site-packages\comtypes\tools\codegenerator.py", line 185, in generate
File "site-packages\comtypes\tools\codegenerator.py", line 629, in External
File "site-packages\comtypes\client_generate.py", line 110, in GetModule
File "site-packages\comtypes\client_generate.py", line 184, in _CreateWrapper
File "site-packages\comtypes\client_generate.py", line 24, in _my_import
ModuleNotFoundError: No module named 'comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0'
vasily-v-ryabov commentedon Jul 22, 2020
Hi @Wang-zhipeng this is completely different problem. First you need to know that
comtypesgenerates Python code for UIAutomationCore.dll on the fly and saves it to cached .py file which is missing in your case (_00020430_0000_0000_C000_000000000046_0_2_0.py). The file name contains GUID of the COM library. You need some trick with PyInstaller to include this cached file into your executable.yixue99 commentedon Aug 15, 2021
I use pyinstaller build to exe, and run exe on another system that has no python environment, it can't run. my python version 3.9.4,UIAutomation version 2.0.15
junkmd commentedon Feb 4, 2024
Note:
reported in python/cpython#16799, resolved (reverted) in python/cpython#17960,
and fixed in Python 3.7.7 and 3.8.2.
From python/cpython#16799 (comment)