Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

python - 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:ESRIPythonSolstice_Tools_ScriptsPrinter_ToolsBatch_Print_From_PDF_OnlyBatchprintFromPDFOnly_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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...