pywin32

win32com import error python 3.4 [duplicate]

一笑奈何 提交于 2019-11-29 03:57:06
This question already has an answer here: import win32api error in Python 2.6 10 answers I just installed python 3.4 64bit and tried to install win32com. I have downloaded pywin32-218.win-amd64-py3.4.exe and ran it without any problem. pip freeze reports pywin32==218. However, when I try to import win32com.client I get following error: Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> import win32com.client File "C:\program files\Python34\lib\site-packages\win32com\__init__.py", line 5, in <module> import win32api, sys, os ImportError: DLL load failed: The specified

How to install win32com module in a virtualenv?

寵の児 提交于 2019-11-29 02:52:15
问题 I have installed both virtualenv and pywin32 on my Windows 7 64-bit laptop, and each of them seems to work, but not with each other. More specifically, if a virtualenv is active, then running import win32com.client in a python interactive shell fails with No module named win32com.client . The same expression succeeds, however, if no virtualenv is active. When I try to install pywin32 with pip (which is how I normally install modules when a virtualenv is active), I get the error: Could not

Is there a way to decode numerical COM error-codes in pywin32

早过忘川 提交于 2019-11-29 01:49:02
问题 Here is part of a stack-trace from a recent run of an unreliable application written in Python which controls another application written in Excel: pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146788248), None) Obviously something has gone wrong ... but what?[1] These COM error codes seem to be excessively cryptic. How can I decode this error message? Is there a table somewhere that allows me to convert this numerical error code into something more

Error installing and running pywin32 2.7

与世无争的帅哥 提交于 2019-11-28 23:17:17
I am coming up with a couple errors after installing: pywin32-217.win32-py2.7 I have recently upgraded ArcGIS to 10.1 and it uses Python 2.7 (as opposed to 2.6 that came with ArcGIS 10.0) When I run the installer on a Windows 7 64 bit, it installs, but throws the following message: close failed in file object destructor: sys.excepthook is missing lost sys.stderr I had a simple python script to print to a printer from a folder containing .pdf files which worked before my upgrade import arcpy, glob, win32api, os pdfLoc = arcpy.GetParameterAsText(0) try: copies = int(arcpy.GetParameter(1)) except

Common ways to connect to odbc from python on windows? [closed]

回眸只為那壹抹淺笑 提交于 2019-11-28 22:29:37
问题 What library should I use to connect to odbc from python on windows? Is there a good alternative for pywin32 when it comes to odbc? I'm looking for something well-documented, robust, actively maintained, etc. pyodbc looks good -- are there any others? 回答1: You already suggested pyodbc , and I am going to agree with you. It has given me the least amount of issues in my experience; I've used pymssql and adodbapi, and when those threw exceptions/created issues, I swapped out the code and

How do I read a jpg or png from the windows clipboard in python and vice versa?

▼魔方 西西 提交于 2019-11-28 19:42:18
I have an image (jpg, png, etc.) in the windows clipboard. I'd like to save it to a file. win32clipboard would seem to be the answer, but every example I can find deals with text. copy an image to the clipboard, then import win32clipboard win32clipboard.OpenClipboard() data = win32clipboard.GetClipboardData() with open(name, 'wb') as f: f.write(data) win32clipboard.CloseClipboard() fails with TypeError: Specified clipboard format is not available I'd also like to do the reverse - given an image file, write it to the clipboard. Gerrat I would just use Pillow : from PIL import ImageGrab im =

How can I determine the display idle time from Python in Windows, Linux, and MacOS?

≯℡__Kan透↙ 提交于 2019-11-28 17:46:00
问题 I would like to know how long it's been since the user last hit a key or moved the mouse - not just in my application, but on the whole "computer" (i.e. display), in order to guess whether they're still at the computer and able to observe notifications that pop up on the screen. I'd like to do this purely from (Py)GTK+, but I am amenable to calling platform-specific functions. Ideally I'd like to call functions which have already been wrapped from Python, but if that's not possible, I'm not

win32file.ReadDirectoryChangesW doesn't find all moved files

蹲街弑〆低调 提交于 2019-11-28 14:32:00
Good morning, I've come across a peculiar problem with a program I'm creating in Python. It appears that when I drag and drop files from one location to another, not all of the files are registered as events by the modules. I've been working with win32file and win32con to try an get all events related to moving files from one location to another for processing. Here is a snip bit of my detection code: import win32file import win32con def main(): path_to_watch = 'D:\\' _file_list_dir = 1 # Create a watcher handle _h_dir = win32file.CreateFile( path_to_watch, _file_list_dir, win32con.FILE_SHARE

How to control the size of the Windows shell window from within a python script?

烈酒焚心 提交于 2019-11-28 12:45:36
When launching a script-type python file from Windows you get a windows shell type window where the script runs. How can the script determine and also set/control the Window Size, Screen Buffer Size and Window Position of said window?. I suspect this can be done with the pywin32 module but I can't find how. You can do this using the SetConsoleWindowInfo function from the win32 API. The following should work: from ctypes import windll, byref from ctypes.wintypes import SMALL_RECT STDOUT = -11 hdl = windll.kernel32.GetStdHandle(STDOUT) rect = wintypes.SMALL_RECT(0, 50, 50, 80) # (left, top,

Python/Tkinter: Turn on/off screen updates like wxPython Freeze/Thaw?

故事扮演 提交于 2019-11-28 11:41:01
问题 Does Tkinter provide a way to temporarily turn off screen updates (when performing a large amount of screen activity) and then turn on screen updates when the UI updates are complete? Many GUI frameworks have this feature. wxPython provides Freeze and Thaw methods for this functionality. The Windows Win32api supports this as well via LockWindowUpdate( hWnd | 0 ). Googling on "tkinter freeze thaw" and "tkinter lockwindowupdate" came up emtpy. 回答1: No, Tkinter has no such thing. However, the