Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing and running pywin32 2.7

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:
    copies = 1

for pdfname in glob.glob(os.path.join(pdfLoc, "*.pdf")):
    fullpath = os.path.join(pdfLoc, pdfname)
    for copy in range(copies):
        win32api.ShellExecute(0, "print", pdfname, None, ".", 0)

del fullpath
del pdfname
del pdfLoc

Now when I run the script, I get the following error:

Traceback (most recent call last): File "Z:\ESRI\Python\Solstice_Tools_Scripts\Printer_Tools\Batch_Print_From_PDF_Only\BatchprintFromPDFOnly_Test.py", line 34, in win32api.ShellExecute(0, "print", pdfname, None, ".", 0) error: (31, 'ShellExecute', 'A device attached to the system is not functioning.')

Failed to execute (BatchPrintFromPDFOnly2).

I've been googling around and have tried a few solutions, like running the executable in troubleshooting mode, but the error persists. Can anyone suggest what may cause this?

As a side note, I upgraded 4 computers in my company to the new version of python and ArcGIS, and only one of them is throwing this error. The rest work fine.

Thanks, Mike

like image 798
Mike Avatar asked Jun 19 '12 17:06

Mike


People also ask

Does pywin32 work on 64 bit?

There is no pywin64 . But pywin32 has 64-bit builds.

How do I check my pywin32 version?

Occasionally you will need to know what version of software you are using. The normal way to find this information out is usually done by opening the program, going to its Help menu and clicking the About menu item.

Can pywin32 run on Linux?

1 Answer. Show activity on this post. You can't install pywin32 on Kali Linux because it's only available for Windows. It provides access to the Win32 APIs and to COM objects, and a Python program intended to work on any Linux distribution shouldn't need those (or it should only attempt to use them conditionally).


2 Answers

I had the same problem, but solved it a bit differently. Instead of creating another admin account, I was able to execute the pywin32-217.win32-py2.7.exe successfully from a command prompt that I started with Run as Administrator.

like image 54
Rina Rivera Avatar answered Sep 22 '22 12:09

Rina Rivera


An alternate solution is what Mark Hammond suggests on the pywin32 mailing list:

This seems to happen if User Access Control (UAC) is disabled - is it disabled for you?

Either way, try running "python scripts\pywin32_postinstall.py -install" from the root of the install directory and things should finish registering - that should fix the next error you see.

This worked fine for me.

like image 32
Gerrat Avatar answered Sep 19 '22 12:09

Gerrat