From tierox at gmail.com Thu Jun 1 05:28:59 2023 From: tierox at gmail.com (Gualtiero Scotti) Date: Thu, 1 Jun 2023 11:28:59 +0200 Subject: [python-win32] How to enable pywin to evaluate -X utf8 flag Message-ID: Hi, I need to start my python application through windows service. For this purpose I use pywin32. I'm not able to make a Python instance to evaluate the -X uf8 flag. This flag must be passed during python invocation only and not when it is already started. After some investigations I've found the service launch *pythonservice.exe* wrapper but I don't know how to pass the flag to the Python interpreter. Is there another option to set this flag? It is possible to set an env variable *PYTHONUTF8=1 * but pythonservice.exe doesn't seem to evaluate it... *My environment* *- Windows 11 Home 22H2* *- Python 3.11.1* (tags/v3.11.1:a7a450f, Dec 6 2022, 19:43:28) [MSC v.1934 32 bit (Intel)] on win32 - *Pywin32 305* - *Pywin32-ctypes 0.2.0* *Python documentation* 4.7. UTF-8 mode? New in version 3.7. Windows still uses legacy encodings for the system encoding (the ANSI Code Page). Python uses it for the default encoding of text files (e.g. locale.getencoding() ). This may cause issues because UTF-8 is widely used on the internet and most Unix systems, including WSL (Windows Subsystem for Linux). You can use the Python UTF-8 Mode to change the default text encoding to UTF-8. You can enable the Python UTF-8 Mode via the -X utf8 command line option, or the PYTHONUTF8=1 environment variable. See PYTHONUTF8 for enabling UTF-8 mode, and Excursus: Setting environment variables for how to modify environment variables. When the Python UTF-8 Mode is enabled, you can still use the system encoding (the ANSI Code Page) via the ?mbcs? codec. Note that adding PYTHONUTF8=1 to the default environment variables will affect all Python 3.7+ applications on your system. If you have any Python 3.7+ applications which rely on the legacy system encoding, it is recommended to set the environment variable temporarily or use the -X utf8 command line option. Note Even when UTF-8 mode is disabled, Python uses UTF-8 by default on Windows for: - Console I/O including standard I/O (see *PEP 528* for details). - The filesystem encoding (see *PEP 529* for details). from -> https://docs.python.org/3/using/windows.html Please help me! Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Jun 1 11:05:29 2023 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 1 Jun 2023 11:05:29 -0400 Subject: [python-win32] How to enable pywin to evaluate -X utf8 flag In-Reply-To: References: Message-ID: https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py is a demo of using a service using python.exe and supports specifying the command-line, so that might be an option? Mark On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote: > Hi, I need to start my python application through windows service. For > this purpose I use pywin32. > I'm not able to make a Python instance to evaluate the -X uf8 flag. > > This flag must be passed during python invocation only and not when it > is already started. > After some investigations I've found the service launch > *pythonservice.exe* wrapper but I don't know how to pass the flag to > the Python interpreter. > > Is there another option to set this flag??It is possible to set an env > variable *PYTHONUTF8=1 *?but pythonservice.exe doesn't?seem to > evaluate it... > * > * > *My environment* > *- Windows 11 Home 22H2* > *-?Python 3.11.1*?(tags/v3.11.1:a7a450f, Dec ?6 2022, 19:43:28) [MSC > v.1934 32 bit (Intel)] on win32 > - *Pywin32 305* > - *Pywin32-ctypes 0.2.0* > > *Python documentation* > > > 4.7. UTF-8 mode? > > > New in version 3.7. > > Windows still uses legacy encodings for the system encoding (the ANSI > Code Page). Python uses it for the default encoding of text files > (e.g. |locale.getencoding()| > ). > > This may cause issues because UTF-8 is widely used on the internet and > most Unix systems, including WSL (Windows Subsystem for Linux). > > You can use the Python UTF-8 Mode > ?to change the > default text encoding to UTF-8. You can enable the Python UTF-8 Mode > ?via the |-X > utf8|?command line option, or the |PYTHONUTF8=1|?environment variable. > See |PYTHONUTF8| > ?for > enabling UTF-8 mode, and Excursus: Setting environment variables > ?for how > to modify environment variables. > > When the Python UTF-8 Mode > ?is enabled, you > can still use the system encoding (the ANSI Code Page) via the ?mbcs? > codec. > > Note that adding |PYTHONUTF8=1|?to the default environment variables > will affect all Python 3.7+ applications on your system. If you have > any Python 3.7+ applications which rely on the legacy system encoding, > it is recommended to set the environment variable temporarily or use > the |-X utf8|?command line option. > > Note > > Even when UTF-8 mode is disabled, Python uses UTF-8 by default on > Windows for: > > * > > Console I/O including standard I/O (see *PEP 528* > ?for details). > > * > > The filesystem encoding > ?(see > *PEP 529* ?for details). > > from -> https://docs.python.org/3/using/windows.html > > Please help me! > Thanks in advance > * > * > > _______________________________________________ > 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 bill at tutts.org Thu Jun 1 13:08:49 2023 From: bill at tutts.org (Bill Tutt) Date: Thu, 1 Jun 2023 13:08:49 -0400 Subject: [python-win32] Setting Focus Assist Mode via COM In-Reply-To: References: <485248794.3882013.1685365314860.ref@mail.yahoo.com> <485248794.3882013.1685365314860@mail.yahoo.com> <20c4023be3a043a590e7f3e4195abab8@manross.net> <1712290564.2446579.1685511106225@mail.yahoo.com> Message-ID: This IDL snippet from the GIST contains the GUID you're looking for: [uuid(f53321fa-34f8-4b7f-b9a3-361877cb94cf)] coclass QuietHoursSettings { [default] interface IQuietHoursSettings; } coclass's are the COM object. The interface guid you mentioned is that you need to supply to QueryInterface once you've created the COM object. NOTE: Those COM interfaces don't inherit from IDispatch (and aren't dual) so even the universal vtable code that was written once upon a time might have some issues with the data types in some of the methods in the IQuietHoursSettings. (Assuming that the IDL definitions in the GIST match reality since this COM object isn't actually documented publicly.) I haven't done this for literally decades, so take this for what it is worth (almost nothing). So, you might have a simpler time of it exposing a C API from a small custom DLL that uses the C++ sample code you mentioned and consume that via ctypes, or come up with some wrapper objects you expose via a new Python extension DLL. If you're really determined, you could add pywin32 style support for the interfaces in a new DLL without too much grief. (But it is a fairly tedious process and would probably involve learning more about how the pywin32 COM goo works on the inside of the source code) Bill On Wed, May 31, 2023 at 2:53?PM Steven Manross wrote: > Interfaces are definitely different and cannot be used with IDispatch, etc. > > > > Someone with more experience might be able to direct you to something, but > as far as I know, that?s reserved for C++ (or likely ctypes in python? but > that?s on the fringe of what I?m capable of helping with ? and completely > outside the scope of the pywin32 module). > > > > But to make it more clear.. ctypes is how python can call things like > that C++ code, but my one endeavor into that space was a VERY long and > frustrating road as making sure that all the prerequisite data structures > were created (and defined correctly) was a daunting task, and someone ended > up figuring it out for me ? as I was totally missing different structures > that needed to be defined (it was for some data from Terminal Server that > is not publicly supported ? but totally capable of being read from Windows). > > > > HTH > > > > Steven > > *From:* python-win32 *On > Behalf Of *name zero via python-win32 > *Sent:* Tuesday, May 30, 2023 10:32 PM > *To:* python-win32 at python.org > *Subject:* Re: [python-win32] Setting Focus Assist Mode via COM > > > > Hi, > > > > thanks for explaining the issue with clsids. > > > > The "application" is basically part of MS Windows. Talking to it via COM > is 100% possible, as the C++ code (that is part of the GitHub-Gist) > demonstrates > . > It just doesn't work with pywin32. > > > > When I look for "6bff4732-81ec-4ffb-ae67-b6c1bc29631f" in the Windows > registry, I only find an entry in "HKEY_CLASSES_ROOT\Interface" (there is > no entry in HKEY_CLASSES_ROOT\clsid) with a default value of > "IQuietHoursSettings". But win32com.client.Dispatch('IQuietHoursSettings') > fails with the error message "Invalid class string". > > > > Best regards! > > > > > > On Tuesday, May 30, 2023 at 11:41:25 PM GMT+2, Steven Manross < > steven at manross.net> wrote: > > > > > > While I haven?t worked on exactly what you are working on: > > > > I?d first verify suggest that the application that installs this class > needs to be installed on the PC you are trying to create the automation > from, because ?Class not Registered? isn?t a python error, and it talks > more directly to the fact that the appropriate class from the software you > are trying to automate isn?t on the computer you are running python from: > so either you have the wrong CLSID or are doing something else wrong > (missing software???). > > > > Classes are listed in the registry here: > > > > HKEY_CLASSES_ROOT\clsid\{6bff4732-81ec-4ffb-ae67-b6c1bc29631f} > > ? and your CLSID would need to exist (as installed from whatever software > you are trying to automate) prior to python being able to automate it. > > > > Here is an example that should work on your system? > > > > ms_dict = win32com.client.Dispatch('Scripting.Dictionary') > > > > ? because the scripting dictionary object class is installed in just about > every Windows OS since pre-WindowsXP > > > > I hope this helps. Enjoy your day. > > > > Steven > > *From:* python-win32 *On > Behalf Of *name zero via python-win32 > *Sent:* Monday, May 29, 2023 6:02 AM > *To:* python-win32 at python.org > *Subject:* [python-win32] Setting Focus Assist Mode via COM > > > > Hi, > > > > could someone help me out with first steps for how to set Focus Assist via > COM, which > https://gist.github.com/riverar/085d98ffb1343e92225a10817109b2e3 > demonstrates for a C++ code base? Something like > > > > win32com.client.Dispatch('{6bff4732-81ec-4ffb-ae67-b6c1bc29631f}', > clsctx=pythoncom.CLSCTX_LOCAL_SERVER) > > > > fails with "pywintypes.com_error: (-2147221164, 'Class not registered', > None, None)" > > > > Thank you and best regards! > _______________________________________________ > 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 namezero911 at yahoo.com Thu Jun 1 14:08:59 2023 From: namezero911 at yahoo.com (name zero) Date: Thu, 1 Jun 2023 18:08:59 +0000 (UTC) Subject: [python-win32] Setting Focus Assist Mode via COM In-Reply-To: References: <485248794.3882013.1685365314860.ref@mail.yahoo.com> <485248794.3882013.1685365314860@mail.yahoo.com> <20c4023be3a043a590e7f3e4195abab8@manross.net> <1712290564.2446579.1685511106225@mail.yahoo.com> Message-ID: <1049224476.998185.1685642939080@mail.yahoo.com> Hey, thanks for your hints. I guess my easiest option would be to build a C++ CLI (.exe) from the code in the Gist and just call it with "subprocess.check_output()". Best regards On Thursday, June 1, 2023 at 07:09:02 PM GMT+2, Bill Tutt wrote: This IDL snippet from the GIST contains the GUID you're looking for:?[uuid(f53321fa-34f8-4b7f-b9a3-361877cb94cf)] coclass QuietHoursSettings { ? ? [default] interface IQuietHoursSettings; } coclass's are the COM object. The interface guid you mentioned is that you need to supply to QueryInterface once you've created the COM object. NOTE: Those COM interfaces don't inherit from IDispatch (and aren't dual) so even the universal vtable code that was written once upon a time might have some issues with the data types in some of the methods in the IQuietHoursSettings. (Assuming that the IDL definitions in the GIST match reality since this COM object isn't actually documented publicly.) I haven't done this for literally?decades,? so take this for what it is worth (almost nothing).? So, you might have a simpler time of it exposing a C API from a small custom DLL that uses the C++ sample code you mentioned and consume that via ctypes,?or come up with some wrapper objects you expose via a new Python extension DLL. If you're really determined, you could add pywin32 style support for the interfaces in a new DLL without too much grief. (But it is a fairly tedious process and would probably involve learning more about how the pywin32 COM goo works on the inside of the source code) Bill On Wed, May 31, 2023 at 2:53?PM Steven Manross wrote: Interfaces are definitely different and cannot be used with IDispatch, etc. ? Someone with more experience might be able to direct you to something, but as far as I know, that?s reserved for C++ (or likely ctypes in python?? but that?s on the fringe of what I?m capable of helping with ? and completely outside the scope of the pywin32 module). ? But to make it more clear..? ctypes is how python can call things like that C++ code, but my one endeavor into that space was a VERY long and frustrating road as making sure that all the prerequisite data structures were created (and defined correctly) was a daunting task, and someone ended up figuring it out for me ? as I was totally missing different structures that needed to be defined (it was for some data from Terminal Server that is not publicly supported ? but totally capable of being read from Windows). ? HTH ? Steven From: python-win32 On Behalf Of name zero via python-win32 Sent: Tuesday, May 30, 2023 10:32 PM To: python-win32 at python.org Subject: Re: [python-win32] Setting Focus Assist Mode via COM ? Hi, ? thanks for explaining the issue with clsids. ? The "application" is basically part of MS Windows. Talking to it via COM is 100% possible, as the C++ code (that is part of the GitHub-Gist)demonstrates. It just doesn't work with pywin32. ? When I look for "6bff4732-81ec-4ffb-ae67-b6c1bc29631f" in the Windows registry, I only find an entry in "HKEY_CLASSES_ROOT\Interface" (there is no entry in HKEY_CLASSES_ROOT\clsid) with a default value of? "IQuietHoursSettings". But win32com.client.Dispatch('IQuietHoursSettings') fails with the error message "Invalid class string". ? Best regards! ? ? On Tuesday, May 30, 2023 at 11:41:25 PM GMT+2, Steven Manross wrote: ? ? While I haven?t worked on exactly what you are working on: ? I?d first verify suggest that the application that installs this class needs to be installed on the PC you are trying to create the automation from, because ?Class not Registered? isn?t a python error, and it talks more directly to the fact that the appropriate class from the software you are trying to automate isn?t on the computer you are running python from: so either you have the wrong CLSID or are doing something else wrong (missing software???). ? Classes are listed in the registry here: ? HKEY_CLASSES_ROOT\clsid\{6bff4732-81ec-4ffb-ae67-b6c1bc29631f} ? and your CLSID would need to exist (as installed from whatever software you are trying to automate) prior to python being able to automate it. ? Here is an example that should work on your system? ? ms_dict = win32com.client.Dispatch('Scripting.Dictionary') ? ? because the scripting dictionary object class is installed in just about every Windows OS since pre-WindowsXP ? I hope this helps.? Enjoy your day. ? Steven From: python-win32 On Behalf Of name zero via python-win32 Sent: Monday, May 29, 2023 6:02 AM To: python-win32 at python.org Subject: [python-win32] Setting Focus Assist Mode via COM ? Hi, ? could someone help me out with first steps for how to set Focus Assist via COM, whichhttps://gist.github.com/riverar/085d98ffb1343e92225a10817109b2e3 demonstrates for a C++ code base? Something like ? win32com.client.Dispatch('{6bff4732-81ec-4ffb-ae67-b6c1bc29631f}', clsctx=pythoncom.CLSCTX_LOCAL_SERVER) ? fails with "pywintypes.com_error: (-2147221164, 'Class not registered', None, None)" ? Thank you and best regards! _______________________________________________ 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 jbowen at infinitecactus.com Thu Jun 1 18:57:21 2023 From: jbowen at infinitecactus.com (Jason Bowen) Date: Thu, 1 Jun 2023 17:57:21 -0500 Subject: [python-win32] stat fields seem wrong when accessing files over SMB on Windows In-Reply-To: <1049224476.998185.1685642939080@mail.yahoo.com> References: <485248794.3882013.1685365314860.ref@mail.yahoo.com> <485248794.3882013.1685365314860@mail.yahoo.com> <20c4023be3a043a590e7f3e4195abab8@manross.net> <1712290564.2446579.1685511106225@mail.yahoo.com> <1049224476.998185.1685642939080@mail.yahoo.com> Message-ID: <06dd6f34-3b38-aaa0-725e-4adf2a25768f@infinitecactus.com> Hey Python on Windows folks, I just wanted to send this as a heads up about what seems to be a bug I've run into with newer pre-GA releases of Python 3.12 (cf. 3.12a7 and 3.12b1). I've filed an issue on the CPython repo: https://github.com/python/cpython/issues/105212 The gist is that up to 3.12a6 I get meaningful information from stat (either os.stat or pathlib.Path.stat) from a file accessed from a Windows Server 2019 VM over SMB 3.1 and after upgrading beyond that I get all zeros for time fields. The offending commit seems to be this one: https://github.com/python/cpython/commit/0f175766e27642108c65bba04bbd54dcf8799b0e Just a heads up for folks who might be playing with Python 3.12 early (now with pathlib.Path.walk!) in a Windows/CIFS/SMB environment. I still have a feeling I'm going to be told that I'm "holding it wrong" with this (and I welcome it if that's the case). Cheers! From tierox at gmail.com Tue Jun 6 02:56:19 2023 From: tierox at gmail.com (Gualtiero Scotti) Date: Tue, 6 Jun 2023 08:56:19 +0200 Subject: [python-win32] How to enable pywin to evaluate -X utf8 flag In-Reply-To: References: Message-ID: HI Mark and Hi all, as I wrote previously Mark's solution did not work for me. I need pythonsevice.exe is able to pass -X utf8 parameter to python interpreter or in alternative is able to evaluate evaluate the environment variable PYTHONUTF8=1. Any suggestions? Please help me. Thanks in advance Il giorno lun 5 giu 2023 alle ore 10:51 Gualtiero Scotti ha scritto: > HI Mark, > I've tried your solution but it doesn't work. When calling python > directly, service fails to start. > When i use > #_exe_name_ = sys.executable > #_exe_args_ = ' -X utf8 ' + '"' + os.path.abspath(sys.argv[0]) + '"' > service are directly linked to my python app without using > pythonservice.exe. ( I saw this on Regedit) > > *As you wrote on your example:* > > > # This is an example of a service hosted by python.exe rather than > # pythonservice.exe. > > # *Note that it is very rare that using python.exe is a better option* > # than the default pythonservice.exe - the latter has better error handling > # so that if Python itself can't be initialized or there are very early > # i*mport errors, you will get error details written to the event log*. > When > # using python.exe instead, you are forced to wait for the interpreter > startup > # and imports to succeed before you are able to effectively setup your own > # error handling. > > > *# So in short, please make sure you *really* want to do this, otherwise > just# stick with the default.* > > I need to use pythonservice.exe but I don't understand how it wraps my > python application. Is there a way to tell to pythonservice.exe to call > python with some interpreter arguments? > Thanks in advance. > > > Il giorno gio 1 giu 2023 alle ore 17:05 Mark Hammond < > skippy.hammond at gmail.com> ha scritto: > >> >> https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py >> is a demo of using a service using python.exe and supports specifying the >> command-line, so that might be an option? >> >> Mark >> On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote: >> >> Hi, I need to start my python application through windows service. For >> this purpose I use pywin32. >> I'm not able to make a Python instance to evaluate the -X uf8 flag. >> >> This flag must be passed during python invocation only and not when it is >> already started. >> After some investigations I've found the service launch >> *pythonservice.exe* wrapper but I don't know how to pass the flag to the >> Python interpreter. >> >> Is there another option to set this flag? It is possible to set an env >> variable *PYTHONUTF8=1 * but pythonservice.exe doesn't seem to evaluate >> it... >> >> *My environment* >> *- Windows 11 Home 22H2* >> *- Python 3.11.1* (tags/v3.11.1:a7a450f, Dec 6 2022, 19:43:28) [MSC >> v.1934 32 bit (Intel)] on win32 >> - *Pywin32 305* >> - *Pywin32-ctypes 0.2.0* >> >> *Python documentation* >> 4.7. UTF-8 mode? >> >> >> New in version 3.7. >> >> Windows still uses legacy encodings for the system encoding (the ANSI >> Code Page). Python uses it for the default encoding of text files (e.g. >> locale.getencoding() >> ). >> >> This may cause issues because UTF-8 is widely used on the internet and >> most Unix systems, including WSL (Windows Subsystem for Linux). >> >> You can use the Python UTF-8 Mode >> to change the >> default text encoding to UTF-8. You can enable the Python UTF-8 Mode >> via the -X utf8 command >> line option, or the PYTHONUTF8=1 environment variable. See PYTHONUTF8 >> for >> enabling UTF-8 mode, and Excursus: Setting environment variables >> for how >> to modify environment variables. >> >> When the Python UTF-8 Mode >> is enabled, you >> can still use the system encoding (the ANSI Code Page) via the ?mbcs? codec. >> >> Note that adding PYTHONUTF8=1 to the default environment variables will >> affect all Python 3.7+ applications on your system. If you have any Python >> 3.7+ applications which rely on the legacy system encoding, it is >> recommended to set the environment variable temporarily or use the -X >> utf8 command line option. >> >> Note >> >> >> Even when UTF-8 mode is disabled, Python uses UTF-8 by default on Windows >> for: >> >> - >> >> Console I/O including standard I/O (see *PEP 528* >> for details). >> - >> >> The filesystem encoding >> >> (see *PEP 529* for details). >> >> from -> https://docs.python.org/3/using/windows.html >> >> Please help me! >> Thanks in advance >> >> >> _______________________________________________ >> python-win32 mailing listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Tue Jun 6 09:05:40 2023 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 6 Jun 2023 09:05:40 -0400 Subject: [python-win32] How to enable pywin to evaluate -X utf8 flag In-Reply-To: References: Message-ID: <8535b5cd-a9ff-2886-d0c1-26b840b33856@skippinet.com.au> pythonservice.exe doesn't "wrap" python.exe - it's a stand-alone executable which embeds Python. Thus there's no way to pass a cmd-line param to python.exe as python.exe isn't involved. You could patch pythonservice.exe to handle that arg, then do whatever it is python.exe does with that arg. If you told me more about what went wrong with using python.exe as the executable for the service we might be able to work something out there, but "doesn't work" has never been a useful starting point. Cheers, Mark On 2023-06-06 2:56 a.m., Gualtiero Scotti wrote: > HI Mark and Hi all, > as I wrote previously?Mark's solution did not work for me. I need > pythonsevice.exe is able to pass -X utf8 parameter to python > interpreter or in alternative is able to evaluate evaluate the > environment variable?PYTHONUTF8=1. Any suggestions? > Please help me. > Thanks in?advance > > > Il giorno lun 5 giu 2023 alle ore 10:51 Gualtiero Scotti > ha scritto: > > HI Mark, > I've tried your solution but it doesn't work. When calling python > directly, service fails to start. > When i use > #_exe_name_ = sys.executable #_exe_args_ = ' -X utf8 ' + '"' + > os.path.abspath(sys.argv[0]) + '"' > service are directly linked to my python?app without using > pythonservice.exe. ( I saw this on Regedit) > > _As you wrote on your example:_ > _ > _ > > # This is an example of a service hosted by python.exe rather than > # pythonservice.exe. > > # *Note that it is very rare that using python.exe is a better option* > # than the default pythonservice.exe - the latter has better error > handling > # so that if Python itself can't be initialized or there are very > early > # i*mport errors, you will get error details written to the event > log*.? When > # using python.exe instead, you are forced to wait for the > interpreter startup > # and imports to succeed before you are able to effectively setup > your own > # error handling. > > *# So in short, please make sure you *really* want to do this, > otherwise just > # stick with the default.* > * > * > ?I need to use pythonservice.exe but I don't understand how it > wraps my python application. Is there a way to tell to > pythonservice.exe to call python with some interpreter arguments? > Thanks in advance. > * > * > > Il giorno gio 1 giu 2023 alle ore 17:05 Mark Hammond > ha scritto: > > https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py > is a demo of using a service using python.exe and supports > specifying the command-line, so that might be an option? > > Mark > > On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote: >> Hi, I need to start my python application through windows >> service. For this purpose I use pywin32. >> I'm not able to make a Python instance to evaluate the -X uf8 >> flag. >> >> This flag must be passed during python invocation only and >> not when it is already started. >> After some investigations I've found the service launch >> *pythonservice.exe* wrapper but I don't know how to pass the >> flag to the Python interpreter. >> >> Is there another option to set this flag??It is possible to >> set an env variable *PYTHONUTF8=1 *?but pythonservice.exe >> doesn't?seem to evaluate it... >> * >> * >> *My environment* >> *- Windows 11 Home 22H2* >> *-?Python 3.11.1*?(tags/v3.11.1:a7a450f, Dec ?6 2022, >> 19:43:28) [MSC v.1934 32 bit (Intel)] on win32 >> - *Pywin32 305* >> - *Pywin32-ctypes 0.2.0* >> >> *Python documentation* >> >> >> 4.7. UTF-8 mode? >> >> >> New in version 3.7. >> >> Windows still uses legacy encodings for the system encoding >> (the ANSI Code Page). Python uses it for the default encoding >> of text files (e.g. |locale.getencoding()| >> ). >> >> This may cause issues because UTF-8 is widely used on the >> internet and most Unix systems, including WSL (Windows >> Subsystem for Linux). >> >> You can use the Python UTF-8 Mode >> ?to >> change the default text encoding to UTF-8. You can enable the >> Python UTF-8 Mode >> ?via the >> |-X utf8|?command line option, or the >> |PYTHONUTF8=1|?environment variable. See |PYTHONUTF8| >> ?for >> enabling UTF-8 mode, and Excursus: Setting environment >> variables >> ?for >> how to modify environment variables. >> >> When the Python UTF-8 Mode >> ?is >> enabled, you can still use the system encoding (the ANSI Code >> Page) via the ?mbcs? codec. >> >> Note that adding |PYTHONUTF8=1|?to the default environment >> variables will affect all Python 3.7+ applications on your >> system. If you have any Python 3.7+ applications which rely >> on the legacy system encoding, it is recommended to set the >> environment variable temporarily or use the |-X utf8|?command >> line option. >> >> Note >> >> Even when UTF-8 mode is disabled, Python uses UTF-8 by >> default on Windows for: >> >> * >> >> Console I/O including standard I/O (see *PEP 528* >> ?for details). >> >> * >> >> The filesystem encoding >> ?(see >> *PEP 529* ?for details). >> >> from -> https://docs.python.org/3/using/windows.html >> >> Please help me! >> Thanks in advance >> * >> * >> >> _______________________________________________ >> 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 tierox at gmail.com Tue Jun 6 09:57:45 2023 From: tierox at gmail.com (Gualtiero Scotti) Date: Tue, 6 Jun 2023 15:57:45 +0200 Subject: [python-win32] How to enable pywin to evaluate -X utf8 flag In-Reply-To: <8535b5cd-a9ff-2886-d0c1-26b840b33856@skippinet.com.au> References: <8535b5cd-a9ff-2886-d0c1-26b840b33856@skippinet.com.au> Message-ID: Thank you Mark for your response, and your explanation.You are right, python.exe is not involved but I thought you handled the flag in your embedded calls.. When I try to start service it doesn't start and the error message is: *Error starting service: The service did not respond to the start or control request in a timely fashion.* _svc_name_ = 'XXXXXXXXXXXXXXX' _svc_display_name_ = 'XXXXXXXXXXXXXXXXXXX' _svc_description_ = 'SXXXXXXXXXXXXXXX' _exe_name_ = sys.executable _exe_args_ = '-X utf8 "' + os.path.abspath(__file__) + '"' When I take a look to the service on Regedit I've the following situation: ImagePath = *"C:\Program Files (x86)\snapp-device-manager-win32\Python\python.exe" -X utf8 "C:\Program Files (x86)\xxxxxxxxxxxxxx\winservice_launcher32.py"* I can't find any logs about failure.... windows doesn't help me...... [image: image.png] Thanks in advance for your availability. Best regards Il giorno mar 6 giu 2023 alle ore 15:05 Mark Hammond < mhammond at skippinet.com.au> ha scritto: > pythonservice.exe doesn't "wrap" python.exe - it's a stand-alone > executable which embeds Python. Thus there's no way to pass a cmd-line > param to python.exe as python.exe isn't involved. You could patch > pythonservice.exe to handle that arg, then do whatever it is python.exe > does with that arg. > > If you told me more about what went wrong with using python.exe as the > executable for the service we might be able to work something out there, > but "doesn't work" has never been a useful starting point. > > Cheers, > > Mark > On 2023-06-06 2:56 a.m., Gualtiero Scotti wrote: > > HI Mark and Hi all, > as I wrote previously Mark's solution did not work for me. I need > pythonsevice.exe is able to pass -X utf8 parameter to python interpreter or > in alternative is able to evaluate evaluate the environment > variable PYTHONUTF8=1. Any suggestions? > Please help me. > Thanks in advance > > > Il giorno lun 5 giu 2023 alle ore 10:51 Gualtiero Scotti > ha scritto: > >> HI Mark, >> I've tried your solution but it doesn't work. When calling python >> directly, service fails to start. >> When i use >> #_exe_name_ = sys.executable #_exe_args_ = ' -X utf8 ' + '"' + >> os.path.abspath(sys.argv[0]) + '"' >> service are directly linked to my python app without using >> pythonservice.exe. ( I saw this on Regedit) >> >> *As you wrote on your example:* >> >> >> # This is an example of a service hosted by python.exe rather than >> # pythonservice.exe. >> >> # *Note that it is very rare that using python.exe is a better option* >> # than the default pythonservice.exe - the latter has better error >> handling >> # so that if Python itself can't be initialized or there are very early >> # i*mport errors, you will get error details written to the event log*. >> When >> # using python.exe instead, you are forced to wait for the interpreter >> startup >> # and imports to succeed before you are able to effectively setup your own >> # error handling. >> >> >> *# So in short, please make sure you *really* want to do this, otherwise >> just # stick with the default.* >> >> I need to use pythonservice.exe but I don't understand how it wraps my >> python application. Is there a way to tell to pythonservice.exe to call >> python with some interpreter arguments? >> Thanks in advance. >> >> >> Il giorno gio 1 giu 2023 alle ore 17:05 Mark Hammond < >> skippy.hammond at gmail.com> ha scritto: >> >>> >>> https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py >>> is a demo of using a service using python.exe and supports specifying the >>> command-line, so that might be an option? >>> >>> Mark >>> On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote: >>> >>> Hi, I need to start my python application through windows service. For >>> this purpose I use pywin32. >>> I'm not able to make a Python instance to evaluate the -X uf8 flag. >>> >>> This flag must be passed during python invocation only and not when it >>> is already started. >>> After some investigations I've found the service launch >>> *pythonservice.exe* wrapper but I don't know how to pass the flag to >>> the Python interpreter. >>> >>> Is there another option to set this flag? It is possible to set an env >>> variable *PYTHONUTF8=1 * but pythonservice.exe doesn't seem to evaluate >>> it... >>> >>> *My environment* >>> *- Windows 11 Home 22H2* >>> *- Python 3.11.1* (tags/v3.11.1:a7a450f, Dec 6 2022, 19:43:28) [MSC >>> v.1934 32 bit (Intel)] on win32 >>> - *Pywin32 305* >>> - *Pywin32-ctypes 0.2.0* >>> >>> *Python documentation* >>> 4.7. UTF-8 mode? >>> >>> >>> New in version 3.7. >>> >>> Windows still uses legacy encodings for the system encoding (the ANSI >>> Code Page). Python uses it for the default encoding of text files (e.g. >>> locale.getencoding() >>> ). >>> >>> This may cause issues because UTF-8 is widely used on the internet and >>> most Unix systems, including WSL (Windows Subsystem for Linux). >>> >>> You can use the Python UTF-8 Mode >>> to change the >>> default text encoding to UTF-8. You can enable the Python UTF-8 Mode >>> via the -X utf8 command >>> line option, or the PYTHONUTF8=1 environment variable. See PYTHONUTF8 >>> for >>> enabling UTF-8 mode, and Excursus: Setting environment variables >>> for how >>> to modify environment variables. >>> >>> When the Python UTF-8 Mode >>> is enabled, you >>> can still use the system encoding (the ANSI Code Page) via the ?mbcs? codec. >>> >>> Note that adding PYTHONUTF8=1 to the default environment variables will >>> affect all Python 3.7+ applications on your system. If you have any Python >>> 3.7+ applications which rely on the legacy system encoding, it is >>> recommended to set the environment variable temporarily or use the -X >>> utf8 command line option. >>> >>> Note >>> >>> >>> Even when UTF-8 mode is disabled, Python uses UTF-8 by default on >>> Windows for: >>> >>> - >>> >>> Console I/O including standard I/O (see *PEP 528* >>> for details). >>> - >>> >>> The filesystem encoding >>> >>> (see *PEP 529* for details). >>> >>> from -> https://docs.python.org/3/using/windows.html >>> >>> Please help me! >>> Thanks in advance >>> >>> >>> _______________________________________________ >>> python-win32 mailing listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 >>> >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 64598 bytes Desc: not available URL: From mhammond at skippinet.com.au Tue Jun 6 10:38:03 2023 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 6 Jun 2023 10:38:03 -0400 Subject: [python-win32] How to enable pywin to evaluate -X utf8 flag In-Reply-To: References: <8535b5cd-a9ff-2886-d0c1-26b840b33856@skippinet.com.au> Message-ID: That error typically means your Python code raised an exception before the service could be started. You probably need some way to track that down - eg, some way to discover stdout/stderr from your service - win32traceutil etc might help depending on how the service is configured. Does the demo itself work? Does it work without the command-line mods? Mark On 2023-06-06 9:57 a.m., Gualtiero Scotti wrote: > Thank you Mark for your response, and your explanation.You are right, > python.exe is not involved but?I thought you handled the flag in your > embedded calls.. > When I try to start service it doesn't start and the error message? is: > * > Error starting service: The service did not respond to the start or > control request in a timely fashion.* > * > * > _svc_name_ = 'XXXXXXXXXXXXXXX' _svc_display_name_ = > 'XXXXXXXXXXXXXXXXXXX' _svc_description_ = 'SXXXXXXXXXXXXXXX' > _exe_name_ = sys.executable _exe_args_ = '-X utf8 "' + > os.path.abspath(__file__) + '"' > * > * > When I take a look to the service on Regedit I've the following situation: > ImagePath = *"C:\Program Files > (x86)\snapp-device-manager-win32\Python\python.exe" -X utf8 > "C:\Program Files (x86)\xxxxxxxxxxxxxx\winservice_launcher32.py"* > I can't find any logs about failure.... windows doesn't help me...... > image.png > > Thanks in advance for your availability. > Best regards > > Il giorno mar 6 giu 2023 alle ore 15:05 Mark Hammond > ha scritto: > > pythonservice.exe doesn't "wrap" python.exe - it's a stand-alone > executable which embeds Python. Thus there's no way to pass a > cmd-line param to python.exe as python.exe isn't involved. You > could patch pythonservice.exe to handle that arg, then do whatever > it is python.exe does with that arg. > > If you told me more about what went wrong with using python.exe as > the executable for the service we might be able to work something > out there, but "doesn't work" has never been a useful starting point. > > Cheers, > > Mark > > On 2023-06-06 2:56 a.m., Gualtiero Scotti wrote: >> HI Mark and Hi all, >> as I wrote previously?Mark's solution did not work for me. I need >> pythonsevice.exe is able to pass -X utf8 parameter to python >> interpreter or in alternative is able to evaluate evaluate the >> environment variable?PYTHONUTF8=1. Any suggestions? >> Please help me. >> Thanks in?advance >> >> >> Il giorno lun 5 giu 2023 alle ore 10:51 Gualtiero Scotti >> ha scritto: >> >> HI Mark, >> I've tried your solution but it doesn't work. When calling >> python directly, service fails to start. >> When i use >> #_exe_name_ = sys.executable #_exe_args_ = ' -X utf8 ' + '"' >> + os.path.abspath(sys.argv[0]) + '"' >> service are directly linked to my python?app without using >> pythonservice.exe. ( I saw this on Regedit) >> >> _As you wrote on your example:_ >> _ >> _ >> >> # This is an example of a service hosted by python.exe rather >> than >> # pythonservice.exe. >> >> # *Note that it is very rare that using python.exe is a >> better option* >> # than the default pythonservice.exe - the latter has better >> error handling >> # so that if Python itself can't be initialized or there are >> very early >> # i*mport errors, you will get error details written to the >> event log*.? When >> # using python.exe instead, you are forced to wait for the >> interpreter startup >> # and imports to succeed before you are able to effectively >> setup your own >> # error handling. >> >> *# So in short, please make sure you *really* want to do >> this, otherwise just >> # stick with the default.* >> * >> * >> ?I need to use pythonservice.exe but I don't understand how >> it wraps my python application. Is there a way to tell to >> pythonservice.exe to call python with some interpreter arguments? >> Thanks in advance. >> * >> * >> >> Il giorno gio 1 giu 2023 alle ore 17:05 Mark Hammond >> ha scritto: >> >> https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py >> is a demo of using a service using python.exe and >> supports specifying the command-line, so that might be an >> option? >> >> Mark >> >> On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote: >>> Hi, I need to start my python application through >>> windows service. For this purpose I use pywin32. >>> I'm not able to make a Python instance to evaluate the >>> -X uf8 flag. >>> >>> This flag must be passed during python invocation only >>> and not when it is already started. >>> After some investigations I've found the service launch >>> *pythonservice.exe* wrapper but I don't know how to pass >>> the flag to the Python interpreter. >>> >>> Is there another option to set this flag??It is possible >>> to set an env variable *PYTHONUTF8=1 *?but >>> pythonservice.exe doesn't?seem to evaluate it... >>> * >>> * >>> *My environment* >>> *- Windows 11 Home 22H2* >>> *-?Python 3.11.1*?(tags/v3.11.1:a7a450f, Dec ?6 2022, >>> 19:43:28) [MSC v.1934 32 bit (Intel)] on win32 >>> - *Pywin32 305* >>> - *Pywin32-ctypes 0.2.0* >>> >>> *Python documentation* >>> >>> >>> 4.7. UTF-8 mode? >>> >>> >>> New in version 3.7. >>> >>> Windows still uses legacy encodings for the system >>> encoding (the ANSI Code Page). Python uses it for the >>> default encoding of text files (e.g. >>> |locale.getencoding()| >>> ). >>> >>> This may cause issues because UTF-8 is widely used on >>> the internet and most Unix systems, including WSL >>> (Windows Subsystem for Linux). >>> >>> You can use the Python UTF-8 Mode >>> ?to >>> change the default text encoding to UTF-8. You can >>> enable the Python UTF-8 Mode >>> ?via >>> the |-X utf8|?command line option, or the >>> |PYTHONUTF8=1|?environment variable. See |PYTHONUTF8| >>> ?for >>> enabling UTF-8 mode, and Excursus: Setting environment >>> variables >>> ?for >>> how to modify environment variables. >>> >>> When the Python UTF-8 Mode >>> ?is >>> enabled, you can still use the system encoding (the ANSI >>> Code Page) via the ?mbcs? codec. >>> >>> Note that adding |PYTHONUTF8=1|?to the default >>> environment variables will affect all Python 3.7+ >>> applications on your system. If you have any Python 3.7+ >>> applications which rely on the legacy system encoding, >>> it is recommended to set the environment variable >>> temporarily or use the |-X utf8|?command line option. >>> >>> Note >>> >>> Even when UTF-8 mode is disabled, Python uses UTF-8 by >>> default on Windows for: >>> >>> * >>> >>> Console I/O including standard I/O (see *PEP 528* >>> ?for details). >>> >>> * >>> >>> The filesystem encoding >>> ?(see >>> *PEP 529* ?for >>> details). >>> >>> from -> https://docs.python.org/3/using/windows.html >>> >>> Please help me! >>> Thanks in advance >>> * >>> * >>> >>> _______________________________________________ >>> 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 64598 bytes Desc: not available URL: From tierox at gmail.com Tue Jun 6 11:07:51 2023 From: tierox at gmail.com (Gualtiero Scotti) Date: Tue, 6 Jun 2023 17:07:51 +0200 Subject: [python-win32] How to enable pywin to evaluate -X utf8 flag In-Reply-To: References: <8535b5cd-a9ff-2886-d0c1-26b840b33856@skippinet.com.au> Message-ID: Thank you Mark, I'm going to try... I haven't tried your demo yet. My code doesn't work with or without the command line change Best regards Il giorno mar 6 giu 2023 alle ore 16:38 Mark Hammond < mhammond at skippinet.com.au> ha scritto: > That error typically means your Python code raised an exception before the > service could be started. You probably need some way to track that down - > eg, some way to discover stdout/stderr from your service - win32traceutil > etc might help depending on how the service is configured. Does the demo > itself work? Does it work without the command-line mods? > > Mark > On 2023-06-06 9:57 a.m., Gualtiero Scotti wrote: > > Thank you Mark for your response, and your explanation.You are right, > python.exe is not involved but I thought you handled the flag in your > embedded calls.. > When I try to start service it doesn't start and the error message is: > > * Error starting service: The service did not respond to the start or > control request in a timely fashion.* > > _svc_name_ = 'XXXXXXXXXXXXXXX' _svc_display_name_ = 'XXXXXXXXXXXXXXXXXXX' _svc_description_ > = 'SXXXXXXXXXXXXXXX' _exe_name_ = sys.executable _exe_args_ = '-X utf8 "' + > os.path.abspath(__file__) + '"' > > When I take a look to the service on Regedit I've the following situation: > ImagePath = *"C:\Program Files > (x86)\snapp-device-manager-win32\Python\python.exe" -X utf8 "C:\Program > Files (x86)\xxxxxxxxxxxxxx\winservice_launcher32.py"* > I can't find any logs about failure.... windows doesn't help me...... > [image: image.png] > > Thanks in advance for your availability. > Best regards > > Il giorno mar 6 giu 2023 alle ore 15:05 Mark Hammond < > mhammond at skippinet.com.au> ha scritto: > >> pythonservice.exe doesn't "wrap" python.exe - it's a stand-alone >> executable which embeds Python. Thus there's no way to pass a cmd-line >> param to python.exe as python.exe isn't involved. You could patch >> pythonservice.exe to handle that arg, then do whatever it is python.exe >> does with that arg. >> >> If you told me more about what went wrong with using python.exe as the >> executable for the service we might be able to work something out there, >> but "doesn't work" has never been a useful starting point. >> >> Cheers, >> >> Mark >> On 2023-06-06 2:56 a.m., Gualtiero Scotti wrote: >> >> HI Mark and Hi all, >> as I wrote previously Mark's solution did not work for me. I need >> pythonsevice.exe is able to pass -X utf8 parameter to python interpreter or >> in alternative is able to evaluate evaluate the environment >> variable PYTHONUTF8=1. Any suggestions? >> Please help me. >> Thanks in advance >> >> >> Il giorno lun 5 giu 2023 alle ore 10:51 Gualtiero Scotti < >> tierox at gmail.com> ha scritto: >> >>> HI Mark, >>> I've tried your solution but it doesn't work. When calling python >>> directly, service fails to start. >>> When i use >>> #_exe_name_ = sys.executable #_exe_args_ = ' -X utf8 ' + '"' + >>> os.path.abspath(sys.argv[0]) + '"' >>> service are directly linked to my python app without using >>> pythonservice.exe. ( I saw this on Regedit) >>> >>> *As you wrote on your example:* >>> >>> >>> # This is an example of a service hosted by python.exe rather than >>> # pythonservice.exe. >>> >>> # *Note that it is very rare that using python.exe is a better option* >>> # than the default pythonservice.exe - the latter has better error >>> handling >>> # so that if Python itself can't be initialized or there are very early >>> # i*mport errors, you will get error details written to the event log*. >>> When >>> # using python.exe instead, you are forced to wait for the interpreter >>> startup >>> # and imports to succeed before you are able to effectively setup your >>> own >>> # error handling. >>> >>> >>> *# So in short, please make sure you *really* want to do this, otherwise >>> just # stick with the default.* >>> >>> I need to use pythonservice.exe but I don't understand how it wraps my >>> python application. Is there a way to tell to pythonservice.exe to call >>> python with some interpreter arguments? >>> Thanks in advance. >>> >>> >>> Il giorno gio 1 giu 2023 alle ore 17:05 Mark Hammond < >>> skippy.hammond at gmail.com> ha scritto: >>> >>>> >>>> https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py >>>> is a demo of using a service using python.exe and supports specifying the >>>> command-line, so that might be an option? >>>> >>>> Mark >>>> On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote: >>>> >>>> Hi, I need to start my python application through windows service. For >>>> this purpose I use pywin32. >>>> I'm not able to make a Python instance to evaluate the -X uf8 flag. >>>> >>>> This flag must be passed during python invocation only and not when it >>>> is already started. >>>> After some investigations I've found the service launch >>>> *pythonservice.exe* wrapper but I don't know how to pass the flag to >>>> the Python interpreter. >>>> >>>> Is there another option to set this flag? It is possible to set an env >>>> variable *PYTHONUTF8=1 * but pythonservice.exe doesn't seem to >>>> evaluate it... >>>> >>>> *My environment* >>>> *- Windows 11 Home 22H2* >>>> *- Python 3.11.1* (tags/v3.11.1:a7a450f, Dec 6 2022, 19:43:28) [MSC >>>> v.1934 32 bit (Intel)] on win32 >>>> - *Pywin32 305* >>>> - *Pywin32-ctypes 0.2.0* >>>> >>>> *Python documentation* >>>> 4.7. UTF-8 mode? >>>> >>>> >>>> New in version 3.7. >>>> >>>> Windows still uses legacy encodings for the system encoding (the ANSI >>>> Code Page). Python uses it for the default encoding of text files (e.g. >>>> locale.getencoding() >>>> ). >>>> >>>> This may cause issues because UTF-8 is widely used on the internet and >>>> most Unix systems, including WSL (Windows Subsystem for Linux). >>>> >>>> You can use the Python UTF-8 Mode >>>> to change the >>>> default text encoding to UTF-8. You can enable the Python UTF-8 Mode >>>> via the -X utf8 command >>>> line option, or the PYTHONUTF8=1 environment variable. See PYTHONUTF8 >>>> for >>>> enabling UTF-8 mode, and Excursus: Setting environment variables >>>> for how >>>> to modify environment variables. >>>> >>>> When the Python UTF-8 Mode >>>> is enabled, you >>>> can still use the system encoding (the ANSI Code Page) via the ?mbcs? codec. >>>> >>>> Note that adding PYTHONUTF8=1 to the default environment variables >>>> will affect all Python 3.7+ applications on your system. If you have any >>>> Python 3.7+ applications which rely on the legacy system encoding, it is >>>> recommended to set the environment variable temporarily or use the -X >>>> utf8 command line option. >>>> >>>> Note >>>> >>>> >>>> Even when UTF-8 mode is disabled, Python uses UTF-8 by default on >>>> Windows for: >>>> >>>> - >>>> >>>> Console I/O including standard I/O (see *PEP 528* >>>> for details). >>>> - >>>> >>>> The filesystem encoding >>>> >>>> (see *PEP 529* for details). >>>> >>>> from -> https://docs.python.org/3/using/windows.html >>>> >>>> Please help me! >>>> Thanks in advance >>>> >>>> >>>> _______________________________________________ >>>> python-win32 mailing listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 >>>> >>>> -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 64598 bytes Desc: not available URL: From oudouxin at gmail.com Wed Jun 7 09:18:53 2023 From: oudouxin at gmail.com (Wuping Xin) Date: Wed, 07 Jun 2023 13:18:53 +0000 Subject: [python-win32] Question about pywin32 and Anaconda In-Reply-To: References: Message-ID: pywin32_postinstall.py, line 406, "SKIP_ANACONDA", why? Does that mean Anaconda is NOT whole-heartedly supported by pywin32? From skippy.hammond at gmail.com Wed Jun 7 11:38:22 2023 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 7 Jun 2023 11:38:22 -0400 Subject: [python-win32] Question about pywin32 and Anaconda In-Reply-To: References: Message-ID: pywin32_postinstall.py (https://github.com/mhammond/pywin32/blob/main/pywin32_postinstall.py) does not mention anaconda. The fact anaconda ships a version of pywin32 with it has caused problems though - maybe that's in a fork of theirs? If so, you need to ask them. Mark On 2023-06-07 9:18 a.m., Wuping Xin wrote: > pywin32_postinstall.py, line 406, "SKIP_ANACONDA", why? > > Does that mean Anaconda is NOT whole-heartedly supported by pywin32? > _______________________________________________ > 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 oudouxin at gmail.com Wed Jun 7 11:42:33 2023 From: oudouxin at gmail.com (Wuping Xin) Date: Wed, 7 Jun 2023 11:42:33 -0400 Subject: [python-win32] Question about pywin32 and Anaconda In-Reply-To: References: Message-ID: You are right. Seems Anaconda adds ?SKIP_ANACONDA? in their customized pywin32_postinstall.py, and the whole COM thing not working with Anaconda On Wed, Jun 7, 2023 at 11:38 AM Mark Hammond wrote: > pywin32_postinstall.py ( > https://github.com/mhammond/pywin32/blob/main/pywin32_postinstall.py) > does not mention anaconda. > > The fact anaconda ships a version of pywin32 with it has caused problems > though - maybe that's in a fork of theirs? If so, you need to ask them. > > Mark > On 2023-06-07 9:18 a.m., Wuping Xin wrote: > > pywin32_postinstall.py, line 406, "SKIP_ANACONDA", why? > > Does that mean Anaconda is NOT whole-heartedly supported by pywin32? > _______________________________________________ > 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 wuping at caliper.com Thu Jun 29 14:15:27 2023 From: wuping at caliper.com (Wuping Xin) Date: Thu, 29 Jun 2023 18:15:27 +0000 Subject: [python-win32] Python Active Scripting Error - should I ignore it? In-Reply-To: References: <1528ce55-1bd4-7966-d46f-3c3ffc3db47a@skippinet.com.au> <7cc2794e-1834-ee05-593c-9b1d54b1eb5b@skippinet.com.au> <4287db71-984c-60e7-c533-0f6b1101daca@skippinet.com.au> Message-ID: When I running a Python Active Script, DebugView captured the following errrors - any advice? [22076] File "C:\Users\.\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axscript\client\framework.py", line 729, in SetScriptSite [22076] from . import debug [22076] File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axscript\client\debug.py", line 9, in [22076] from win32com.axdebug import adb, axdebug, contexts, documents, gateways, stackframe [22076] File "C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axdebug\documents.py", line 37, in [22076] class DebugDocumentText( [22076] TypeError: Cannot create a consistent method resolution [22076] order (MRO) for bases DebugDocumentInfo, DebugDocumentText, DebugDocument [22076] *** Debugger Manager could not initialize - : Cannot create a consistent method resolution [22076] order (MRO) for bases DebugDocumentInfo, DebugDocumentText, DebugDocument -------------- next part -------------- An HTML attachment was scrubbed... URL: From wuping at caliper.com Thu Jun 29 14:29:44 2023 From: wuping at caliper.com (Wuping Xin) Date: Thu, 29 Jun 2023 18:29:44 +0000 Subject: [python-win32] Python Active Scripting Error - should I ignore it? In-Reply-To: References: <1528ce55-1bd4-7966-d46f-3c3ffc3db47a@skippinet.com.au> <7cc2794e-1834-ee05-593c-9b1d54b1eb5b@skippinet.com.au> <4287db71-984c-60e7-c533-0f6b1101daca@skippinet.com.au> Message-ID: OK, I think this is a bug of pywin32, Line 37 of \win32comext\axdebug\documents.py, class DebugDocumentText( gateways.DebugDocumentInfo, gateways.DebugDocumentText, gateways.DebugDocument gateway.DebugDocumentText already inherits from gateway.DebugDocument. This would cause Python to give a Method Resolution Order (MRO) error, because Python cannot determine what class to look methods up on first. There is no need to list gateway.DebugDocument as the parent class, simply class DebugDocumentText( gateways.DebugDocumentInfo, gateways.DebugDocumentText) Agree? ------ Original Message ------ From "Wuping Xin" > To "Python-win32 at python.org" > Date 6/29/2023 2:15:27 PM Subject Python Active Scripting Error - should I ignore it? When I running a Python Active Script, DebugView captured the following errrors - any advice? [22076] File "C:\Users\.\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axscript\client\framework.py", line 729, in SetScriptSite [22076] from . import debug [22076] File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axscript\client\debug.py", line 9, in [22076] from win32com.axdebug import adb, axdebug, contexts, documents, gateways, stackframe [22076] File "C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axdebug\documents.py", line 37, in [22076] class DebugDocumentText( [22076] TypeError: Cannot create a consistent method resolution [22076] order (MRO) for bases DebugDocumentInfo, DebugDocumentText, DebugDocument [22076] *** Debugger Manager could not initialize - : Cannot create a consistent method resolution [22076] order (MRO) for bases DebugDocumentInfo, DebugDocumentText, DebugDocument -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Thu Jun 29 15:29:44 2023 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 29 Jun 2023 15:29:44 -0400 Subject: [python-win32] Python Active Scripting Error - should I ignore it? In-Reply-To: References: <1528ce55-1bd4-7966-d46f-3c3ffc3db47a@skippinet.com.au> <7cc2794e-1834-ee05-593c-9b1d54b1eb5b@skippinet.com.au> <4287db71-984c-60e7-c533-0f6b1101daca@skippinet.com.au> Message-ID: <8449b206-eea3-4ae3-a529-9beab0c7add6@skippinet.com.au> On 2023-06-29 2:29 p.m., Wuping Xin via python-win32 wrote: > OK,? I think this is a bug of pywin32, > > Line 37 of \win32comext\axdebug\documents.py, > > class DebugDocumentText( > ? ? gateways.DebugDocumentInfo, gateways.DebugDocumentText, > gateways.DebugDocument > > ?gateway.DebugDocumentText already inherits from > gateway.DebugDocument.? This would cause Python to give a Method > Resolution Order (MRO) error, because Python cannot determine what > class to look methods up on first. > > There is no need to list gateway.DebugDocument as the parent class, > simply > class DebugDocumentText( > ? ? gateways.DebugDocumentInfo, gateways.DebugDocumentText) > > Agree? That sounds correct to me! Mark > > ------ Original Message ------ > From "Wuping Xin" > To "Python-win32 at python.org" > Date 6/29/2023 2:15:27 PM > Subject Python Active Scripting Error - should I ignore it? > >> When I running a Python Active Script,? DebugView captured the >> following errrors - any advice? >> >> [22076] ? File >> "C:\Users\.\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axscript\client\framework.py", >> line 729, in SetScriptSite >> [22076] ? ? from . import debug >> [22076] ? File >> "C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axscript\client\debug.py", >> line 9, in >> [22076] ? ? from win32com.axdebug import adb, axdebug, contexts, >> documents, gateways, stackframe >> [22076] ? File >> "C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axdebug\documents.py", >> line 37, in >> [22076] ? ? class DebugDocumentText( >> [22076] TypeError: Cannot create a consistent method resolution >> [22076] order (MRO) for bases DebugDocumentInfo, DebugDocumentText, >> DebugDocument >> [22076] *** Debugger Manager could not initialize - > 'TypeError'>: Cannot create a consistent method resolution >> [22076] order (MRO) for bases DebugDocumentInfo, DebugDocumentText, >> DebugDocument > > _______________________________________________ > 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: