From jake at gaynertechnicalservices.com.au Thu Jan 11 01:20:16 2024 From: jake at gaynertechnicalservices.com.au (Jacob Nolan) Date: Thu, 11 Jan 2024 06:20:16 +0000 Subject: [python-win32] PythonService was unable to locate the service manager Message-ID: <0108018cf72db12a-bf384f9a-33b5-4858-8fa5-f2fd05da5cdb-000000@ap-southeast-2.amazonses.com> Currently experiencing this issue on my Windows machine when installing a Windows Service. This is the error output I get from running in the cmd as administrator. Restricting me from being able to run my services. *- PythonService was unable to locate the service manager. Please see the event log for details.** * Here is the output from event viewer application log: |The description for Event ID 14 from source Python Service cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer. If the event originated on another computer, the display information had to be saved with the event. The following information was included with the event: The specified resource type cannot be found in the image file | This issue has happened on each of these version I've tested Python3.11, 3.10.10 and 3.10.8. Currently running Python 3.10.8 64 Bit on Windows Server 2016. - I've installed pywin32 - Run post_install in the root directory of python310 - Installed the service with install flag - Attempted to start service with start flag - PythonService was unable to locate the service manager. Please see the event log for details. -- *Thanks* *Jacob* -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Jan 11 09:19:40 2024 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 11 Jan 2024 09:19:40 -0500 Subject: [python-win32] PythonService was unable to locate the service manager In-Reply-To: <0108018cf72db12a-bf384f9a-33b5-4858-8fa5-f2fd05da5cdb-000000@ap-southeast-2.amazonses.com> References: <0108018cf72db12a-bf384f9a-33b5-4858-8fa5-f2fd05da5cdb-000000@ap-southeast-2.amazonses.com> Message-ID: <63a11f2a-42d0-496e-8604-f3af56fd0bc3@gmail.com> The "" part sounds like it is failing to find Python itself. Where is Python installed? Is it possible the user running the service can't access that location? I believe Python being installed in the default location could cause this if the server is running as any other other than the user which installed Python. Mark On 2024-01-11 1:20 a.m., Jacob Nolan via python-win32 wrote: > > Currently experiencing this issue on my Windows machine when > installing a Windows Service. This is the error output I get from > running in the cmd as administrator. Restricting me from being able to > run my services. > > *- PythonService was unable to locate the service manager. Please see > the event log for details.** > * > > > Here is the output from event viewer application log: > > |The description for Event ID 14 from source Python Service cannot be > found. Either the component that raises this event is not installed on > your local computer or the installation is corrupted. You can install > or repair the component on the local computer. If the event originated > on another computer, the display information had to be saved with the > event. The following information was included with the event: getting traceback - traceback.print_exception() failed> The specified > resource type cannot be found in the image file | > > > This issue has happened on each of these version I've tested > Python3.11, 3.10.10 and 3.10.8. > > Currently running Python 3.10.8 64 Bit on Windows Server 2016. > > - I've installed pywin32 > > - Run post_install in the root directory of python310 > > - Installed the service with install flag > > - Attempted to start service with start flag > > - PythonService was unable to locate the service manager. Please see > the event log for details. > > -- > *Thanks* > *Jacob* > > _______________________________________________ > 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 jake at gaynertechnicalservices.com.au Thu Jan 11 17:46:24 2024 From: jake at gaynertechnicalservices.com.au (Jacob Nolan) Date: Thu, 11 Jan 2024 22:46:24 +0000 Subject: [python-win32] PythonService was unable to locate the service manager In-Reply-To: <63a11f2a-42d0-496e-8604-f3af56fd0bc3@gmail.com> References: <0108018cf72db12a-bf384f9a-33b5-4858-8fa5-f2fd05da5cdb-000000@ap-southeast-2.amazonses.com> <63a11f2a-42d0-496e-8604-f3af56fd0bc3@gmail.com> Message-ID: <0108018cfab4895e-6fbf4ae9-292a-4848-8b90-504eaea39ba3-000000@ap-southeast-2.amazonses.com> I performed a custom install for all users on my E: drive (E:/installs/python3). Added it to the path. It is not under my specific user account. My understanding is this is a global install. I then run it under administrator privileged cmd and successfully install the service. Looking at security permissions for pythonservice.exe in the root python directory. SYSTEM and Admin users have full control. *Jacob Nolan* *Gayner Technical Services* Phone: 0437210168 Email: jake at gaynertechnicalservices.com.au On 1/12/24 01:19, Mark Hammond wrote: > > The "" > part sounds like it is failing to find Python itself. Where is Python > installed? Is it possible the user running the service can't access > that location? I believe Python being installed in the default > location could cause this if the server is running as any other other > than the user which installed Python. > > Mark > > > On 2024-01-11 1:20 a.m., Jacob Nolan via python-win32 wrote: >> >> Currently experiencing this issue on my Windows machine when >> installing a Windows Service. This is the error output I get from >> running in the cmd as administrator. Restricting me from being able >> to run my services. >> >> *- PythonService was unable to locate the service manager. Please see >> the event log for details.** >> * >> >> >> Here is the output from event viewer application log: >> >> |The description for Event ID 14 from source Python Service cannot be >> found. Either the component that raises this event is not installed >> on your local computer or the installation is corrupted. You can >> install or repair the component on the local computer. If the event >> originated on another computer, the display information had to be >> saved with the event. The following information was included with the >> event: >> The specified resource type cannot be found in the image file | >> >> >> This issue has happened on each of these version I've tested >> Python3.11, 3.10.10 and 3.10.8. >> >> Currently running Python 3.10.8 64 Bit on Windows Server 2016. >> >> - I've installed pywin32 >> >> - Run post_install in the root directory of python310 >> >> - Installed the service with install flag >> >> - Attempted to start service with start flag >> >> - PythonService was unable to locate the service manager. Please see >> the event log for details. >> >> -- >> *Thanks* >> *Jacob* >> >> _______________________________________________ >> 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 skippy.hammond at gmail.com Fri Jan 12 10:05:15 2024 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 12 Jan 2024 10:05:15 -0500 Subject: [python-win32] PythonService was unable to locate the service manager In-Reply-To: <0108018cfab4895e-6fbf4ae9-292a-4848-8b90-504eaea39ba3-000000@ap-southeast-2.amazonses.com> References: <0108018cf72db12a-bf384f9a-33b5-4858-8fa5-f2fd05da5cdb-000000@ap-southeast-2.amazonses.com> <63a11f2a-42d0-496e-8604-f3af56fd0bc3@gmail.com> <0108018cfab4895e-6fbf4ae9-292a-4848-8b90-504eaea39ba3-000000@ap-southeast-2.amazonses.com> Message-ID: <66f06069-fd99-4415-ab41-66d995ee68b4@gmail.com> On 2024-01-11 5:46 p.m., Jacob Nolan via python-win32 wrote: > > I performed a custom install for all users on my E: drive > (E:/installs/python3). Added it to the path. It is not under my > specific user account. My understanding is this is a global install. > What exactly is E:? If anything other than a local device it might not be available to the user running the service. > > I then run it under administrator privileged cmd and successfully > install the service. > > Looking at security permissions for pythonservice.exe in the root > python directory. SYSTEM and Admin users have full control. > To be clear, the entire Python tree will need those permissions, not just that .exe. And the question is whether the user running the service has access - SYSTEM and Admin should cover many common scenarios, but not all. You could try configuring the service for your specific user just to see if it works - if it does it would still point to user permissions. Mark > > *Jacob Nolan* > *Gayner Technical Services* > Phone: 0437210168 > Email: jake at gaynertechnicalservices.com.au > On 1/12/24 01:19, Mark Hammond wrote: >> >> The "" >> part sounds like it is failing to find Python itself. Where is Python >> installed? Is it possible the user running the service can't access >> that location? I believe Python being installed in the default >> location could cause this if the server is running as any other other >> than the user which installed Python. >> >> Mark >> >> >> On 2024-01-11 1:20 a.m., Jacob Nolan via python-win32 wrote: >>> >>> Currently experiencing this issue on my Windows machine when >>> installing a Windows Service. This is the error output I get from >>> running in the cmd as administrator. Restricting me from being able >>> to run my services. >>> >>> *- PythonService was unable to locate the service manager. Please >>> see the event log for details.** >>> * >>> >>> >>> Here is the output from event viewer application log: >>> >>> |The description for Event ID 14 from source Python Service cannot >>> be found. Either the component that raises this event is not >>> installed on your local computer or the installation is corrupted. >>> You can install or repair the component on the local computer. If >>> the event originated on another computer, the display information >>> had to be saved with the event. The following information was >>> included with the event: >> traceback.print_exception() failed> The specified resource type >>> cannot be found in the image file | >>> >>> >>> This issue has happened on each of these version I've tested >>> Python3.11, 3.10.10 and 3.10.8. >>> >>> Currently running Python 3.10.8 64 Bit on Windows Server 2016. >>> >>> - I've installed pywin32 >>> >>> - Run post_install in the root directory of python310 >>> >>> - Installed the service with install flag >>> >>> - Attempted to start service with start flag >>> >>> - PythonService was unable to locate the service manager. Please see >>> the event log for details. >>> >>> -- >>> *Thanks* >>> *Jacob* >>> >>> _______________________________________________ >>> python-win32 mailing list >>> python-win32 at python.org >>> https://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > 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 samuel.06 at hotmail.com Fri Jan 12 12:50:40 2024 From: samuel.06 at hotmail.com (Samuel Therrien) Date: Fri, 12 Jan 2024 17:50:40 +0000 Subject: [python-win32] Relevance of very outdated `Pythonwin/pywin/idle` Message-ID: Hi! I recently had to do a deep dive into https://github.com/mhammond/pywin32/tree/main/Pythonwin/pywin/idle as part of a previous PR. See comment: https://github.com/mhammond/pywin32/pull/2102#discussion_r1380422005 Of course it is extremely outdated, but I think the interesting part is that these IDLE modules are now part of the cpython repo (although most have been renamed over time), and some modules seem to not even be used as part of pythonwin. I basically expect that none of this works at all today, especially given the minimum version requirement of Python 3.7-3.8. Is this worth keeping around at all? * Pythonwin will look for IDLE extensions first in this directory, then on the global sys.path. Thus, if you have IDLE installed and run it from the CVS sources, you may remove most of the extensions from this directory, and the latest CVS version will then be used. Could we just delete this entire folder instead, and update references, reducing further maintenance cost and automated tooling churn? Anything special I should look for in testing? [https://opengraph.githubassets.com/b62496876f356f98f081228d039b0186cbce83377c606fe280d33ceba55766fc/mhammond/pywin32/pull/2102] Basic type-checking with mypy and pyright by Avasam ? Pull Request #2102 ? mhammond/pywin32 This is the PR that finally makes basic type-checking validation of public methods possible, easing the addition of 3.7+ type annotations. In its current state, a lot of checks are disabled, and so... github.com ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Fri Jan 12 13:12:40 2024 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 12 Jan 2024 13:12:40 -0500 Subject: [python-win32] Relevance of very outdated `Pythonwin/pywin/idle` In-Reply-To: References: Message-ID: <1988ceea-8fd7-46cb-9ee2-1e642e0b2848@gmail.com> Some of those modules are actually used by pythonwin, particularly by pywin/scintilla - so while I agree the ability to update them is questionable, I don't think just killing the directory makes sense. Did you try to remove it? I'd be surprised if Pythonwin continues to work in that scenario. I also don't see a huge maintenance cost nor must automated tooling churn - I haven't seen much in the way of external PRs touching this, nor have I personally touched these files recently - indeed most of the churn I see if from the *introduction* of such tooling, so one solution to that is probably to not try and introduce new tooling which touches or checks these files. Cheers, Mark On 2024-01-12 12:50 p.m., Samuel Therrien wrote: > Hi! > > I recently had to do a deep dive into > https://github.com/mhammond/pywin32/tree/main/Pythonwin/pywin/idle > ?as > part of a previous PR. See comment: > https://github.com/mhammond/pywin32/pull/2102#discussion_r1380422005 > > > Of course it is extremely outdated, but I think the interesting part > is that these IDLE modules are now part of the cpython repo (although > most have been renamed over time), and some modules seem to not even > be used as part of pythonwin. > > I basically expect that none of this works at all today, especially > given the minimum version requirement of Python 3.7-3.8. Is this worth > keeping around at all? > > * > Pythonwin will look for IDLE extensions first in this directory, > then on the global sys.path. ?Thus, if you have IDLE installed and > run it from the CVS sources, you may remove most of the extensions > from this directory, and the latest CVS version will then be used. > > Could we just delete this entire folder instead, and update > references, reducing further maintenance cost and automated tooling > churn? Anything special I should look for in testing? > > > Basic type-checking with mypy and pyright by Avasam ? Pull Request > #2102 ? mhammond/pywin32 > > This is the PR that finally makes basic type-checking validation of > public methods possible, easing the addition of 3.7+ type annotations. > In its current state, a lot of checks are disabled, and so... > github.com > > /?/ > > > _______________________________________________ > 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 jake at gaynertechnicalservices.com.au Thu Jan 18 01:19:26 2024 From: jake at gaynertechnicalservices.com.au (Jacob Nolan) Date: Thu, 18 Jan 2024 06:19:26 +0000 Subject: [python-win32] PythonService was unable to locate the service manager In-Reply-To: <66f06069-fd99-4415-ab41-66d995ee68b4@gmail.com> References: <0108018cf72db12a-bf384f9a-33b5-4858-8fa5-f2fd05da5cdb-000000@ap-southeast-2.amazonses.com> <63a11f2a-42d0-496e-8604-f3af56fd0bc3@gmail.com> <0108018cfab4895e-6fbf4ae9-292a-4848-8b90-504eaea39ba3-000000@ap-southeast-2.amazonses.com> <66f06069-fd99-4415-ab41-66d995ee68b4@gmail.com> Message-ID: <0108018d1b397434-381b8d04-812e-4b46-ba7c-59c334a28365-000000@ap-southeast-2.amazonses.com> E: is just a local harddrive. The full python install and files under the E: drive is accessible for both the local SYSTEM user, my user and administrator. It is configured to run as the Local System Account. I am successfully able to install the service initially via admin command prompt, and the run it via pywin service debug or using services.msc. But after performing several more service installs I then get this error. It regularly happens and stops any further services from running. I can then reinstall python and it is resolved again. I've asked IT to review any antivirus blocking of files/manipulation of files. They have confirmed there is not. Although I was going to perform checksums on the DLL's and pythonservice.exe. *Jacob Nolan* *Gayner Technical Services* Phone: 0437210168 Email: jake at gaynertechnicalservices.com.au On 1/13/24 02:05, Mark Hammond wrote: > On 2024-01-11 5:46 p.m., Jacob Nolan via python-win32 wrote: >> >> I performed a custom install for all users on my E: drive >> (E:/installs/python3). Added it to the path. It is not under my >> specific user account. My understanding is this is a global install. >> > What exactly is E:? If anything other than a local device it might not > be available to the user running the service. >> >> I then run it under administrator privileged cmd and successfully >> install the service. >> >> Looking at security permissions for pythonservice.exe in the root >> python directory. SYSTEM and Admin users have full control. >> > To be clear, the entire Python tree will need those permissions, not > just that .exe. And the question is whether the user running the > service has access - SYSTEM and Admin should cover many common > scenarios, but not all. You could try configuring the service for your > specific user just to see if it works - if it does it would still > point to user permissions. > > Mark > > > >> >> *Jacob Nolan* >> *Gayner Technical Services* >> Phone: 0437210168 >> Email: jake at gaynertechnicalservices.com.au >> On 1/12/24 01:19, Mark Hammond wrote: >>> >>> The "" >>> part sounds like it is failing to find Python itself. Where is >>> Python installed? Is it possible the user running the service can't >>> access that location? I believe Python being installed in the >>> default location could cause this if the server is running as any >>> other other than the user which installed Python. >>> >>> Mark >>> >>> >>> On 2024-01-11 1:20 a.m., Jacob Nolan via python-win32 wrote: >>>> >>>> Currently experiencing this issue on my Windows machine when >>>> installing a Windows Service. This is the error output I get from >>>> running in the cmd as administrator. Restricting me from being able >>>> to run my services. >>>> >>>> *- PythonService was unable to locate the service manager. Please >>>> see the event log for details.** >>>> * >>>> >>>> >>>> Here is the output from event viewer application log: >>>> >>>> |The description for Event ID 14 from source Python Service cannot >>>> be found. Either the component that raises this event is not >>>> installed on your local computer or the installation is corrupted. >>>> You can install or repair the component on the local computer. If >>>> the event originated on another computer, the display information >>>> had to be saved with the event. The following information was >>>> included with the event: >>> traceback.print_exception() failed> The specified resource type >>>> cannot be found in the image file | >>>> >>>> >>>> This issue has happened on each of these version I've tested >>>> Python3.11, 3.10.10 and 3.10.8. >>>> >>>> Currently running Python 3.10.8 64 Bit on Windows Server 2016. >>>> >>>> - I've installed pywin32 >>>> >>>> - Run post_install in the root directory of python310 >>>> >>>> - Installed the service with install flag >>>> >>>> - Attempted to start service with start flag >>>> >>>> - PythonService was unable to locate the service manager. Please >>>> see the event log for details. >>>> >>>> -- >>>> *Thanks* >>>> *Jacob* >>>> >>>> _______________________________________________ >>>> python-win32 mailing list >>>> python-win32 at python.org >>>> https://mail.python.org/mailman/listinfo/python-win32 >> >> _______________________________________________ >> 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 cheats1551 at gmail.com Thu Jan 18 15:07:24 2024 From: cheats1551 at gmail.com (Michael Litvin) Date: Thu, 18 Jan 2024 15:07:24 -0500 Subject: [python-win32] PyWin32 Advanced Options Message-ID: Hello, I am trying to print from python using the bypass tray on my printer, but I cannot seem to get it working and it always prints from tray 1. Here is my code: image = Image.open(file_path) printer_handle = win32print.OpenPrinter(printer_name) p_info = win32print.GetPrinter(printer_handle, 2) devmode = p_info["pDevMode"] devmode.PaperWidth = 3550 devmode.PaperLength = 8510 devmode.DefaultSource = 4 # bins = win32print.DeviceCapabilities(printer_name, devmode.DeviceName, win32con.DC_BINS) # bin_names = win32print.DeviceCapabilities(printer_name, devmode.DeviceName, win32con.DC_BINNAMES) # for bin, bin_name in zip(bins, bin_names): # print(f"Bin number: {bin}, Bin name: {bin_name}") hDC = win32ui.CreateDC() hDC.CreatePrinterDC(printer_name) hDC.StartDoc(file_path) hDC.StartPage() dib = ImageWin.Dib(image) dib.draw(hDC.GetHandleOutput(), (0, 0, image.size[0],image.size[1])) hDC.EndPage() hDC.EndDoc() hDC.DeleteDC() -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven at manross.net Fri Jan 19 10:43:33 2024 From: steven at manross.net (Steven Manross) Date: Fri, 19 Jan 2024 15:43:33 +0000 Subject: [python-win32] PyWin32 Advanced Options In-Reply-To: References: Message-ID: <8f26ddacc71940bf8031cf5f5e4b6c4e@manross.net> Your mileage may vary, but while using setprinter.exe for a similar task (many years ago) I found that the different trays can sometimes be large values like 260? Your best bet might be to set the tray manually in the UI, and then try to look at those values via something like setprinter.exe The values from setprinter.exe show dmDefaultSource instead of DefaultSource, but it?s all the same If you need setprinter.exe it should be easily downloadable from sourceforge. HTH Steven From: python-win32 On Behalf Of Michael Litvin Sent: Thursday, January 18, 2024 1:07 PM To: python-win32 at python.org Subject: [python-win32] PyWin32 Advanced Options Hello, I am trying to print from python using the bypass tray on my printer, but I cannot seem to get it working and it always prints from tray 1. Here is my code: image = Image.open(file_path) printer_handle = win32print.OpenPrinter(printer_name) p_info = win32print.GetPrinter(printer_handle, 2) devmode = p_info["pDevMode"] devmode.PaperWidth = 3550 devmode.PaperLength = 8510 devmode.DefaultSource = 4 # bins = win32print.DeviceCapabilities(printer_name, devmode.DeviceName, win32con.DC_BINS) # bin_names = win32print.DeviceCapabilities(printer_name, devmode.DeviceName, win32con.DC_BINNAMES) # for bin, bin_name in zip(bins, bin_names): # print(f"Bin number: {bin}, Bin name: {bin_name}") hDC = win32ui.CreateDC() hDC.CreatePrinterDC(printer_name) hDC.StartDoc(file_path) hDC.StartPage() dib = ImageWin.Dib(image) dib.draw(hDC.GetHandleOutput(), (0, 0, image.size[0],image.size[1])) hDC.EndPage() hDC.EndDoc() hDC.DeleteDC() -------------- next part -------------- An HTML attachment was scrubbed... URL: