From pavel.olifer at gmail.com Wed Sep 2 00:26:29 2020 From: pavel.olifer at gmail.com (Pavel Olifer) Date: Wed, 2 Sep 2020 07:26:29 +0300 Subject: [python-win32] opened excel process Message-ID: good morning! In my project I use: python == 3.8 openpyxl == 3.0.5 pywin32 == 228 sometimes after printing excel, the window of the excel process is still open. may be somebody faced with the same problem. I include 2 samples of code which are used in the project. [image: image.png] from openpyxl import load_workbookimport osimport app_config as configimport printers.printers as pfrom datetime import datetimeimport shutilimport time class EditExcelTemplate: def __init__(self, template_name): now = datetime.now() report_name = "_{}{}{}_{}{}{}_{}".format(now.year, now.month, now.day, now.hour, now.minute, now.second, now.microsecond) self.report_path = config.EXCEL_REPORT_PATH.format(template_name + report_name) shutil.copy(src=config.EXCEL_TEMPLATE_PATH.format(template_name), dst=self.report_path) # self.wb = load_workbook(filename=config.EXCEL_TEMPLATE_PATH.format(template_name)) start_load = time.time() self.wb = load_workbook(filename=self.report_path, keep_links=False, keep_vba=False, data_only=True) end_load = time.time() print('LOAD WORKBOOK|{}'.format(str(end_load - start_load))) self.ws = self.wb.active self.answer = {'file_name': template_name.upper()} def write_workbook(self, row_dest, column_dest, value): c = self.ws.cell(row=row_dest, column=column_dest) c.value = value def save_excel(self): self.wb.save(self.report_path) def print_excel(self, printer_no): p.print_excel(printer_no=printer_no, path_to_file=self.report_path) def print_excel_file(self, printer_name): p.print_excel_file(printer_name=printer_name, path_to_file=self.report_path) import win32apiimport app_configimport os, time def print_excel(printer_no, path_to_file): printer_name = app_config.PRINTER_NAMES[printer_no] win32api.ShellExecute( 1, 'printto', path_to_file, '{}'.format(printer_name), '.', 0 ) def delete_file(path_to_file, try_count=1): if os.path.exists(path=path_to_file): file_name = path_to_file.split('\\')[-1] while try_count < 60: try: os.remove(path_to_file) print('File {} deleted!'.format(file_name)) break except PermissionError: print('Can not delete file {}. Hold {} sec.'.format(file_name, try_count)) time.sleep(1.0) try_count += 1 -- -- po +7 (977) 004 67 53 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 214332 bytes Desc: not available URL: From martintrujillor at gmail.com Wed Sep 2 12:04:38 2020 From: martintrujillor at gmail.com (=?UTF-8?Q?Mart=C3=ADn_Trujillo_Raddatz?=) Date: Wed, 2 Sep 2020 12:04:38 -0400 Subject: [python-win32] new error in EnsureDispatch Message-ID: Hi everyone! Before today I was using a script with no problem at all. But today the same script, without any modification, (its a scheduled task) fails with this error: ?Any tip? Traceback (most recent call last): File "C:/Users/mtrujillo/PycharmProjects/pruebas/archivos_opa_siau.py", line 39, in excel = win32.gencache.EnsureDispatch('Excel.Application') File "C:\Users\mtrujillo\PycharmProjects\pruebas\venv\lib\site-packages\win32com\client\gencache.py", line 534, in EnsureDispatch mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand) File "C:\Users\mtrujillo\PycharmProjects\pruebas\venv\lib\site-packages\win32com\client\gencache.py", line 518, in EnsureModule module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "C:\Users\mtrujillo\PycharmProjects\pruebas\venv\lib\site-packages\win32com\client\gencache.py", line 287, in MakeModuleForTypelib makepy.GenerateFromTypeLibSpec( (typelibCLSID, lcid, major, minor), progressInstance=progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "C:\Users\mtrujillo\PycharmProjects\pruebas\venv\lib\site-packages\win32com\client\makepy.py", line 286, in GenerateFromTypeLibSpec gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor) File "C:\Users\mtrujillo\PycharmProjects\pruebas\venv\lib\site-packages\win32com\client\gencache.py", line 548, in AddModuleToCache mod = _GetModule(fname) File "C:\Users\mtrujillo\PycharmProjects\pruebas\venv\lib\site-packages\win32com\client\gencache.py", line 627, in _GetModule mod = __import__(mod_name) ModuleNotFoundError: No module named 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x8' *----------------------------------------* *Mart?n Trujillo Raddatz Puerto Montt - Chile Tel?fono: +59 9 96427814 * *----------------------------------------* -------------- next part -------------- An HTML attachment was scrubbed... URL: From shaiksaleem at armaxindia.com Tue Sep 8 03:47:01 2020 From: shaiksaleem at armaxindia.com (Shaik Saleem Basha) Date: Tue, 8 Sep 2020 13:17:01 +0530 Subject: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) Message-ID: <5FF04C2D-F070-4169-AC73-521D1022FCAC@hxcore.ol> An HTML attachment was scrubbed... URL: From timr at probo.com Tue Sep 8 12:36:00 2020 From: timr at probo.com (Tim Roberts) Date: Tue, 8 Sep 2020 09:36:00 -0700 Subject: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) In-Reply-To: <5FF04C2D-F070-4169-AC73-521D1022FCAC@hxcore.ol> References: <5FF04C2D-F070-4169-AC73-521D1022FCAC@hxcore.ol> Message-ID: Shaik Saleem Basha wrote: > > Hi, > > I?m using python 3.8.5 32 bit ?and also I have installed pywin32 by > this command pip install pywin32 but when I execute my coed i?m > getting the following error pywintypes.com_error: (-2147221005, > 'Invalid class string', None, None) > > My code : > > import?win32com.client > > client?=?win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') > > value?=?client.ReadItemValue('','OPCLabs.KitServer.2', 'Demo.Single') > > print('value:',value) > The most obvious question, of course, is do you actually have the QuickOPC .NET library installed? Why did you choose the 32-bit Python, instead of the 64-bit Python? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3389 bytes Desc: S/MIME Cryptographic Signature URL: From timr at probo.com Tue Sep 8 14:45:37 2020 From: timr at probo.com (Tim Roberts) Date: Tue, 8 Sep 2020 11:45:37 -0700 Subject: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) In-Reply-To: References: <5FF04C2D-F070-4169-AC73-521D1022FCAC@hxcore.ol> Message-ID: <1cc37246-c839-5b0c-a058-1807fe5d7d15@probo.com> Shaik Saleem Basha wrote: > When I downloaded? install python? by default? it installed? 32bit > version only so pywin32 also I installed 32bit only > Quicopc library is installed If QuickOPC is a 64-bit component, then you need to call it from a 64-bit process.? This is not always an easy thing to determine. If a company wants to support both 32-bit and 64-bit processes, then it has to install two different COM servers.? I suggest you describe your problem to the QuickOPC folks; they would know right away if this were the issue. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3389 bytes Desc: S/MIME Cryptographic Signature URL: From shaiksaleem at armaxindia.com Tue Sep 8 12:58:10 2020 From: shaiksaleem at armaxindia.com (Shaik Saleem Basha) Date: Tue, 8 Sep 2020 22:28:10 +0530 Subject: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) In-Reply-To: References: <5FF04C2D-F070-4169-AC73-521D1022FCAC@hxcore.ol> Message-ID: When I downloaded install python by default it installed 32bit version only so pywin32 also I installed 32bit only Quicopc library is installed On Tue, 8 Sep 2020, 22:15 Tim Roberts, wrote: > Shaik Saleem Basha wrote: > > > > Hi, > > > > I?m using python 3.8.5 32 bit and also I have installed pywin32 by > > this command pip install pywin32 but when I execute my coed i?m > > getting the following error pywintypes.com_error: (-2147221005, > > 'Invalid class string', None, None) > > > > My code : > > > > import win32com.client > > > > > client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') > > > > value = client.ReadItemValue('','OPCLabs.KitServer.2', 'Demo.Single') > > > > print('value:',value) > > > The most obvious question, of course, is do you actually have the > QuickOPC .NET library installed? > > Why did you choose the 32-bit Python, instead of the 64-bit Python? > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > _______________________________________________ > 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 shaiksaleem at armaxindia.com Wed Sep 9 00:18:44 2020 From: shaiksaleem at armaxindia.com (Shaik Saleem Basha) Date: Wed, 9 Sep 2020 09:48:44 +0530 Subject: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) In-Reply-To: <1cc37246-c839-5b0c-a058-1807fe5d7d15@probo.com> References: <5FF04C2D-F070-4169-AC73-521D1022FCAC@hxcore.ol> , <1cc37246-c839-5b0c-a058-1807fe5d7d15@probo.com> Message-ID: An HTML attachment was scrubbed... URL: From timr at probo.com Wed Sep 9 02:27:37 2020 From: timr at probo.com (Tim Roberts) Date: Tue, 8 Sep 2020 23:27:37 -0700 Subject: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) In-Reply-To: References: <5FF04C2D-F070-4169-AC73-521D1022FCAC@hxcore.ol> <1cc37246-c839-5b0c-a058-1807fe5d7d15@probo.com> Message-ID: <851B5445-207D-48C2-83CE-9DC520CB7D83@probo.com> On Sep 8, 2020, at 9:18 PM, Shaik Saleem Basha wrote: > > Thank you for your response I will to that . > > But my issue is not only with Quickopc , I have installed OpenOPC in that also I?m getting same error OpenOPC is just a wrapper around the other OPC clients. If you have 64-bit clients, OpenOPC will also fail as well. However, I do not see QuickOPC in the list of classes supported by OpenOPC. > In my Case pywin32 is not matching with the version python I?m using . Why do you think so? You have Python 3.8, and the Pywin32 is for Python 3.8. If there were a mismatch, you couldn?t call Dispatch at all. > Can you please suggest me the versions which I can use to solve this errors , because the same version I?m using in another windows laptop there I?m not getting this errors. Either something has gone wrong with your QuickOPC installation, or you need the 64-bit Python. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From harshkhad at gmail.com Wed Sep 9 12:13:07 2020 From: harshkhad at gmail.com (Harsh Khadloya) Date: Wed, 9 Sep 2020 21:43:07 +0530 Subject: [python-win32] 'module' object has no attribute 'CLSIDToClassMap' strangeness Message-ID: Hi Richard, I am not sure if this email of yours is still valid, but just giving a try. I am getting the same error as you got basis this link . I dont see any reply to it. Can you please help me out if you were able to get to the bottom of it. I am working on Windows on IDLE/Spyder. Thanks Harsh Khadloya -------------- next part -------------- An HTML attachment was scrubbed... URL: From shaiksaleem at armaxindia.com Thu Sep 10 00:08:31 2020 From: shaiksaleem at armaxindia.com (Shaik Saleem Basha) Date: Thu, 10 Sep 2020 09:38:31 +0530 Subject: [python-win32] 'module' object has no attribute 'CLSIDToClassMap' strangeness In-Reply-To: References: Message-ID: <7AAF1B9E-5083-42A7-A8B1-4917DA0655EC@hxcore.ol> An HTML attachment was scrubbed... URL: From qwertyjune56 at gmail.com Thu Sep 10 10:24:26 2020 From: qwertyjune56 at gmail.com (june y) Date: Thu, 10 Sep 2020 23:24:26 +0900 Subject: [python-win32] how to use win32process.CreateRemoteThread Message-ID: i am studying win32process of pywin32. but, i encounter a problem. problem is I don't know win32process.CreateRemoteThread wants what arguments I don't know what *TypeError: Unable to convert function to pointer-sized value*, *TypeError: Unable to convert NoneType to pointer-sized value*, *TypeError: Unable to convert tuple to pointer-sized value* means, import win32processimport win32conimport win32api i=0 def cnt1(): global i print("None") i+=1 def cnt2(a, b): global i print(f"args : {a} {b}") i+=1 pid = win32process.GetCurrentProcessId()print(f"pid : {pid}") pHandle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, win32con.FALSE, pid) a = None b = (1, 2) tHandle1, tid = win32process.CreateRemoteThread(pHandle, None, 0, id(cnt1), id(a), 0)# when id(cnt1) argument is cnt1, error# TypeError: Unable to convert function to pointer-sized value# when id(a) argument is a, error# TypeError: Unable to convert NoneType to pointer-sized value# So I tried to give the address through id(cnt1) and id(a) as parameters of CreateRemoteThread.# but, python IDLE is crashing...(Attachments) tHandle2, tid = win32process.CreateRemoteThread(pHandle, None, 0, id(cnt2), id(b), 0)# same as adove# when id(b) argument is b, error# TypeError: Unable to convert tuple to pointer-sized value print(f"i : {i}") win32api.CloseHandle(tHandle1) win32api.CloseHandle(tHandle2) win32api.CloseHandle(pHandle) it is my code my enviroment is Windows 7 home 64bit, python 3.6.7, pywin32- 224 thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: errerIMG.png Type: image/png Size: 61076 bytes Desc: not available URL: From timr at probo.com Fri Sep 11 03:27:45 2020 From: timr at probo.com (Tim Roberts) Date: Fri, 11 Sep 2020 00:27:45 -0700 Subject: [python-win32] how to use win32process.CreateRemoteThread In-Reply-To: References: Message-ID: <9C2AC11C-39E5-48E9-8D3A-2F2AB77EA7B5@probo.com> On Sep 10, 2020, at 7:24 AM, june y wrote: > > i am studying win32process of pywin32. > > but, i encounter a problem. > > problem is I don't know win32process.CreateRemoteThread wants what arguments > CreateRemoteThread does not work with Python functions. It is a C API, and it expects to be handed the address of a C function in the other process. id(x) returns to you an address, but it?s an address that has to be interpreted by the Python interpreter run-time, and the Python run-time will not be part of the other process. If you want to do threading in Python, use the ?thread? or ?threading? modules. Don?t use win32process for that. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From robin at reportlab.com Tue Sep 15 09:52:28 2020 From: robin at reportlab.com (Robin Becker) Date: Tue, 15 Sep 2020 14:52:28 +0100 Subject: [python-win32] memory leak in extension Message-ID: I am using python-3.8.5 with reportlab to produce charts. I have an ongoing memory issue with a program that uses the reportlab _renderPM extension along with pillow. I don't see the issue in linux (at least I don't see the same linear growth in memory usage I used both objgraph & pympler to see if I could spot dangling objects, but failed to see anything obvious. I have access to the vs 14.2 tools and can probably remember enough C to modify the _renderPM code, but I seek advice on what a suitable approach to detecting leaks in C extensions as I don't think the allocated python objects show growth in the Gb range. -- Robin Becker From joao.arrudaleme at gmail.com Tue Sep 22 08:39:34 2020 From: joao.arrudaleme at gmail.com (=?UTF-8?Q?Jo=C3=A3o_Pedro_Arruda_Leme?=) Date: Tue, 22 Sep 2020 14:39:34 +0200 Subject: [python-win32] Excel cannot open or save Message-ID: Hello, I've been facing a problem when trying to execute a scheduled task (Windows Task Scheduler) that calls a Python script making use of pywin32. The script is very simple, it opens Excel, writes 3 cells, saves and closes it. I can execute it directly by the Administrator and, using runas, I can execute it with every user. When I put it on Task Scheduler to be executed by the administrator it works very well, but as soon as I put to be executed by a different user, I get this error message: Microsoft Excel cannot open or save any more documents because there is not enough available memory or disk space. - To make more memory available, close workbooks or programs you no longer need. - To free disk space, delete files you no longer need from the disk you are saving to. I believe there is a configuration to be made to allow the script to run. Do you have any idea on how to solve this? -- Jo?o Pedro *de Arruda Leme* -------------- next part -------------- An HTML attachment was scrubbed... URL: From shaiksaleem at armaxindia.com Wed Sep 23 00:27:26 2020 From: shaiksaleem at armaxindia.com (Shaik Saleem Basha) Date: Wed, 23 Sep 2020 09:57:26 +0530 Subject: [python-win32] Excel cannot open or save In-Reply-To: References: Message-ID: <629C62B9-13BC-47E5-9090-4E8672B3A6FA@hxcore.ol> An HTML attachment was scrubbed... URL: From patrickbolliger at gmx.ch Thu Sep 24 01:46:02 2020 From: patrickbolliger at gmx.ch (Patrick Bolliger) Date: Thu, 24 Sep 2020 07:46:02 +0200 Subject: [python-win32] Any update on this issue? https://github.com/mhammond/pywin32/issues/1568 Message-ID: <728A5121-BB42-416C-AC60-7EF4586F1FE8@gmx.ch> Hi everybody I experience the same problem as described in the issue (https://github.com/mhammond/pywin32/issues/1568 ). I reached out to Mark Hammond who suggested to ask on this mailing list. Also tried to work with makepy.py -d to identify possible libraries but nothing found. It is my office computer switched from WIn7 to Win10, Excel is 64-bit version (Not having any admin rights, so not possible to investigate very deep) So I am not sure if as the library is called ?win32com? it can not work on 64-bit Excel, so any plans for win64com? :-) If anybody has an idea, thanks a lot. Best regards Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Sep 24 02:17:03 2020 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Sep 2020 23:17:03 -0700 Subject: [python-win32] Any update on this issue? https://github.com/mhammond/pywin32/issues/1568 In-Reply-To: <728A5121-BB42-416C-AC60-7EF4586F1FE8@gmx.ch> References: <728A5121-BB42-416C-AC60-7EF4586F1FE8@gmx.ch> Message-ID: <553BF1C7-2214-407F-9A34-A650BA7506E6@probo.com> On Sep 23, 2020, at 10:46 PM, Patrick Bolliger wrote: > > I experience the same problem as described in the issue (https://github.com/mhammond/pywin32/issues/1568 ). > I reached out to Mark Hammond who suggested to ask on this mailing list. > > Also tried to work with makepy.py -d to identify possible libraries but nothing found. > It is my office computer switched from WIn7 to Win10, Excel is 64-bit version (Not having any admin rights, so not possible to investigate very deep) > > So I am not sure if as the library is called ?win32com? it can not work on 64-bit Excel, so any plans for win64com? :-) If you have a 64-bit Python, then your win32com is a 64-bit library. Exactly which error do you get? That large negative number is a COM error code. Are you sure you still have Excel installed? Are you quite sure it?s a 64-bit Excel? ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3279 bytes Desc: not available URL: From christian.verdumulero at cit.fra-uas.de Fri Sep 25 03:35:50 2020 From: christian.verdumulero at cit.fra-uas.de (Verdu Mulero, Christian) Date: Fri, 25 Sep 2020 07:35:50 +0000 Subject: [python-win32] Accessing shared calendars in Outlook with pywin32 Message-ID: <7B05754D2320944A8EBC3F25FC93A9A72275301F@EXDB1.fh-bks.lokal> I have a little problem. For a department I have to write a script which looks at several shared calendars and evaluates the entries in the calendars. I also have to extract the registered room number from the entered appointments in the calendar. I have tried to solve this problem with pywin32, but I can't find a syntax anywhere to how to access shared calendars and extract the room number from appointments. Hopefully, someone can help me. Best regards, Christian Verdu Mulero -------------- next part -------------- An HTML attachment was scrubbed... URL: From waldemar.osuch at gmail.com Fri Sep 25 21:58:00 2020 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Fri, 25 Sep 2020 19:58:00 -0600 Subject: [python-win32] Accessing shared calendars in Outlook with pywin32 In-Reply-To: <7B05754D2320944A8EBC3F25FC93A9A72275301F@EXDB1.fh-bks.lokal> References: <7B05754D2320944A8EBC3F25FC93A9A72275301F@EXDB1.fh-bks.lokal> Message-ID: https://pypi.org/project/exchangelib/ may be of use. It has very decent documentation with a lot of examples. Cheers, Waldemar On Fri, Sep 25, 2020 at 6:55 PM Verdu Mulero, Christian < christian.verdumulero at cit.fra-uas.de> wrote: > I have a little problem. > > > > For a department I have to write a script which looks at several > shared calendars and evaluates the entries in the calendars. I also have > to extract the registered room number from the entered appointments in > the calendar. > I have tried to solve this problem with pywin32, > but I can't find a syntax anywhere to how > to access shared calendars and extract the room number from appointments. > > Hopefully, someone can help me. > > Best regards, > > Christian Verdu Mulero > _______________________________________________ > 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: