From andrea.gavana at gmail.com Wed Apr 2 04:42:46 2025 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Wed, 2 Apr 2025 10:42:46 +0200 Subject: [python-win32] Failed to load Win32uiApplicationInit Message-ID: Dear PyWin32 users, We have been developing and distributing on Windows a large application over the years. The application is of course in Python, and it gets Cythonized and bundled up with py2exe for distribution. Up until today everything was working fine. We have made no change to any of the dependencies, no change in Python version, no nothing. Just normal evolution of our Python code. However, at application startup we are now getting this message: [image: image.png] I have looked at where this message is generated: https://github.com/mhammond/pywin32/blob/main/Pythonwin/Win32uiHostGlue.h But I have no clue why and how it's possible to get that error. We have been using win32ui for a very long time with no issues. I know it's a long shot, but does anyone have any hint on where to look to find out why this error appears? I have tried with Dependencies X64 but I can't see anything wrong - albeit we have dozens of pyd and dll files and I haven't gone through all of them. Not that they have changed anyway, we haven't changed anything in our Python installation. Thank you in advance for any suggestion. Andrea. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 17969 bytes Desc: not available URL: From matt at mondoinfo.com Wed Apr 2 11:29:27 2025 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 2 Apr 2025 10:29:27 -0500 (CDT) Subject: [python-win32] Windows for ARM on the Microsoft Store Message-ID: <1743603573.34.3653217@mint-julep.mondoinfo.com> I'm not sure that this is the best way to reach the people who are responsible for Python on the Microsoft Store. If someone knows a better way to reach them, please let me know. A couple of days ago over at the python-help mailing list we received an email saying: Hi. I installed Python 3.13 on my laptop that has Windows on ARM. The version from the Microsoft store says AMD64 when you type python into Powershell. Obviously, I expected the native ARM version to be installed. There are no options to install an ARM version on the MS store. Afterwards, I uninstalled it and used the native ARM installer from your website. I just wanted to mention this (x64 versions being installed on aarch64 machines) in case you were not aware of it happening. And I said that I would do my best to get that information into the right hands. Regards, Matt From steven at manross.net Mon Apr 7 12:29:44 2025 From: steven at manross.net (Steven Manross) Date: Mon, 7 Apr 2025 16:29:44 +0000 Subject: [python-win32] Failed to load Win32uiApplicationInit In-Reply-To: References: Message-ID: I am presuming this was installed on a Windows system and therefore testing that the windows installation has no system file linkage issues would be appropriate. While this is a shot in the dark, have you ran: # scan for and fix any issues it finds sfc /scannow # and # to check for windows system file linkage problems DISM /Online /Cleanup-Image /ScanHealth # to fix found issues DISM /Online /Cleanup-Image /RestoreHealth Windows has a habit of messing up while doing windows updates, and ?corrupting? the installation pre se (not copying the right files to the right places). I?ve seen weird issues as a result. While, seemingly, the sfc and dism commands seem to do the same things, Microsoft typically suggests that you run both of these cleanup commands to fix anything that might not have gotten copied properly as they supposedly do slightly different things (but might overlap in some places). HTH Steven From: python-win32 On Behalf Of Andrea Gavana via python-win32 Sent: Wednesday, April 2, 2025 1:43 AM To: python-win32 Mailinglist Subject: [python-win32] Failed to load Win32uiApplicationInit Dear PyWin32 users, We have been developing and distributing on Windows a large application over the years. The application is of course in Python, and it gets Cythonized and bundled up with py2exe for distribution. Up until today everything was working fine. We have made no change to any of the dependencies, no change in Python version, no nothing. Just normal evolution of our Python code. However, at application startup we are now getting this message: [cid:image001.png at 01DBA79F.9829DA80] I have looked at where this message is generated: https://github.com/mhammond/pywin32/blob/main/Pythonwin/Win32uiHostGlue.h But I have no clue why and how it's possible to get that error. We have been using win32ui for a very long time with no issues. I know it's a long shot, but does anyone have any hint on where to look to find out why this error appears? I have tried with Dependencies X64 but I can't see anything wrong - albeit we have dozens of pyd and dll files and I haven't gone through all of them. Not that they have changed anyway, we haven't changed anything in our Python installation. Thank you in advance for any suggestion. Andrea. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 17969 bytes Desc: image001.png URL: From dornech at gmx.de Fri Apr 18 20:33:01 2025 From: dornech at gmx.de (dornech) Date: Sat, 19 Apr 2025 02:33:01 +0200 Subject: [python-win32] Trouble with list iteration / comprehension for wrapped COM objects Message-ID: Hi there, I am working on an EXCEL wrapper to "phytonize" access to EXCEL. I create a wrapper class for all objects classes derived from abasic wrapper class which mainly ensures that calls are snaked-case and pyhtonized calls work. I. e. workbokkobject.SaveAs, workbookobject.saveas and workbokkobject.save_as would all work. This is done by overloaded __getattr__ and __setattr__ methods. The "real" EXCEL object is stored in the attribute "_xlWrapped". The overloaded __getattr__ also ensures that when retrieving f. e. a workbook from the application wrapper, that the resulting EXCEL object is wrapped as well. I. e. let xlapp be my wrapped EXCEL then xlapp.active_workbook would return a reference to a wrapped Workbook object which contains the reference to the "real" EXCEL workbook object in the attribute _xlwrapped. I also overload __getitem__ to allow xlapp[1] as short for xlapp.workbooks(1). Some of these classes I do extend for example to check existence of a worksheet in a workbook. This as very brief introduction. Now I am struggeling with list comprehension and indexes. ??? # access un-wrapped EXCEL ??? print(xlapp._xlWrapped.Workbooks(1).Name) ??? print(xlapp._xlWrapped.Workbooks(2).Name) ??? for i, wb in enumerate(xlapp._xlWrapped.Workbooks): ??????? print(i, wb.Name) ??? # access wrapped EXCEL ??? print(xlapp.Workbooks(1).Name) ??? print(xlapp.Workbooks(2).Name) ??? for i, wb in enumerate(xlapp.Workbooks): ??????? print(i, wb.Name) This prints ??? WB1.xls ??? WB2.xls ??? 0? WB1.xls ??? 1? WB2.xls ??? WB1.xls ??? WB2.xls ?and aborts with an windows/COM error: ?ret = self._oleobj_.InvokeTypes(170, LCID, 2, (13, 0), ((12, 1),),Index ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, None, None, None, 0, -2147352565), None) Obviously when looping via the wrapper object the index is not automatically adjusted. However, I must not increase the index by on in __getitem__ because then the index would alway be increased. It seems, p?ywin32 has some special support for list comprehension and index adjustment for COM objects? I haven't worked with an iterator before but is this the solution? Thanks in advance. Best Christoph From skippy.hammond at gmail.com Fri Apr 18 22:31:16 2025 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 18 Apr 2025 22:31:16 -0400 Subject: [python-win32] Trouble with list iteration / comprehension for wrapped COM objects In-Reply-To: References: Message-ID: <0bec6d86-168e-48ad-ab16-7950d4c23a69@gmail.com> I'm not sure what's going wrong here. Does fetching the list of workspaces as a simple list work? That would be a workaround, and feel free open an issue at https://github.com/mhammond/pywin32 since it shouldn't break that way. Cheers On 2025-04-18 8:33 p.m., dornech via python-win32 wrote: > Hi there, > > I am working on an EXCEL wrapper to "phytonize" access to EXCEL. > > I create a wrapper class for all objects classes derived from abasic > wrapper class which mainly ensures that calls are snaked-case and > pyhtonized calls work. I. e. workbokkobject.SaveAs, > workbookobject.saveas and workbokkobject.save_as would all work. This > is done by overloaded __getattr__ and __setattr__ methods. > > The "real" EXCEL object is stored in the attribute "_xlWrapped". > > The overloaded __getattr__ also ensures that when retrieving f. e. a > workbook from the application wrapper, that the resulting EXCEL object > is wrapped as well. I. e. let xlapp be my wrapped EXCEL then > xlapp.active_workbook would return a reference to a wrapped Workbook > object which contains the reference to the "real" EXCEL workbook > object in the attribute _xlwrapped. > > I also overload __getitem__ to allow xlapp[1] as short for > xlapp.workbooks(1). > > Some of these classes I do extend for example to check existence of a > worksheet in a workbook. > > This as very brief introduction. > > Now I am struggeling with list comprehension and indexes. > > ??? # access un-wrapped EXCEL > ??? print(xlapp._xlWrapped.Workbooks(1).Name) > ??? print(xlapp._xlWrapped.Workbooks(2).Name) > ??? for i, wb in enumerate(xlapp._xlWrapped.Workbooks): > ??????? print(i, wb.Name) > > ??? # access wrapped EXCEL > ??? print(xlapp.Workbooks(1).Name) > ??? print(xlapp.Workbooks(2).Name) > ??? for i, wb in enumerate(xlapp.Workbooks): > ??????? print(i, wb.Name) > > This prints > ??? WB1.xls > ??? WB2.xls > ??? 0? WB1.xls > ??? 1? WB2.xls > ??? WB1.xls > ??? WB2.xls > ?and aborts with an windows/COM error: > > ?ret = self._oleobj_.InvokeTypes(170, LCID, 2, (13, 0), ((12, 1),),Index > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, > None, None, None, 0, -2147352565), None) > > Obviously when looping via the wrapper object the index is not > automatically adjusted. > However, I must not increase the index by on in __getitem__ because > then the index would alway be increased. > > It seems, p?ywin32 has some special support for list comprehension and > index adjustment for COM objects? > I haven't worked with an iterator before but is this the solution? > > Thanks in advance. > > Best > Christoph > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dornech at gmx.de Sat Apr 19 05:16:01 2025 From: dornech at gmx.de (dornech) Date: Sat, 19 Apr 2025 11:16:01 +0200 Subject: [python-win32] Trouble with list iteration / comprehension for wrapped COM objects In-Reply-To: <0bec6d86-168e-48ad-ab16-7950d4c23a69@gmail.com> References: <0bec6d86-168e-48ad-ab16-7950d4c23a69@gmail.com> Message-ID: Hi Mark, thanks for spending time on my question. Sometimes when you are writing, you are already on the way to the solution ... Actually I haven't worked with an iterator object before an was unsure how to do it. But sometimes you must simply try. With an iterator for the Office Collection object wrappers like my wrapper for Applicaiton.Workbooks in addition to the overloaded __getitem__ it seems to work. I plan to publish the package (alongside with a package with a COM object template class package for easening writing COM objects) as soon as I have done some test scripts ready. Probably it is of interest for you and the others here. Best regards Christoph Am 19.04.2025 um 04:31 schrieb Mark Hammond: > > I'm not sure what's going wrong here. Does fetching the list of > workspaces as a simple list work? That would be a workaround, and > feel free open an issue at https://github.com/mhammond/pywin32 since > it shouldn't break that way. > > Cheers > > On 2025-04-18 8:33 p.m., dornech via python-win32 wrote: >> Hi there, >> >> I am working on an EXCEL wrapper to "phytonize" access to EXCEL. >> >> I create a wrapper class for all objects classes derived from abasic >> wrapper class which mainly ensures that calls are snaked-case and >> pyhtonized calls work. I. e. workbokkobject.SaveAs, >> workbookobject.saveas and workbokkobject.save_as would all work. This >> is done by overloaded __getattr__ and __setattr__ methods. >> >> The "real" EXCEL object is stored in the attribute "_xlWrapped". >> >> The overloaded __getattr__ also ensures that when retrieving f. e. a >> workbook from the application wrapper, that the resulting EXCEL >> object is wrapped as well. I. e. let xlapp be my wrapped EXCEL then >> xlapp.active_workbook would return a reference to a wrapped Workbook >> object which contains the reference to the "real" EXCEL workbook >> object in the attribute _xlwrapped. >> >> I also overload __getitem__ to allow xlapp[1] as short for >> xlapp.workbooks(1). >> >> Some of these classes I do extend for example to check existence of a >> worksheet in a workbook. >> >> This as very brief introduction. >> >> Now I am struggeling with list comprehension and indexes. >> >> ??? # access un-wrapped EXCEL >> ??? print(xlapp._xlWrapped.Workbooks(1).Name) >> ??? print(xlapp._xlWrapped.Workbooks(2).Name) >> ??? for i, wb in enumerate(xlapp._xlWrapped.Workbooks): >> ??????? print(i, wb.Name) >> >> ??? # access wrapped EXCEL >> ??? print(xlapp.Workbooks(1).Name) >> ??? print(xlapp.Workbooks(2).Name) >> ??? for i, wb in enumerate(xlapp.Workbooks): >> ??????? print(i, wb.Name) >> >> This prints >> ??? WB1.xls >> ??? WB2.xls >> ??? 0? WB1.xls >> ??? 1? WB2.xls >> ??? WB1.xls >> ??? WB2.xls >> ?and aborts with an windows/COM error: >> >> ?ret = self._oleobj_.InvokeTypes(170, LCID, 2, (13, 0), ((12, 1),),Index >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', >> (0, None, None, None, 0, -2147352565), None) >> >> Obviously when looping via the wrapper object the index is not >> automatically adjusted. >> However, I must not increase the index by on in __getitem__ because >> then the index would alway be increased. >> >> It seems, p?ywin32 has some special support for list comprehension >> and index adjustment for COM objects? >> I haven't worked with an iterator before but is this the solution? >> >> Thanks in advance. >> >> Best >> Christoph >> >> >> >> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32