Python Error 6 The Handle Is Invalid
Contents |
User List Committer List Help Tracker Documentation Tracker Development Report Tracker Problem Issue3905 classification Title: subprocess failing in GUI applications on Windows oserror: [winerror 6] the handle is invalid selenium Type: Stage: needs patch Components: Windows Versions: Python 3.5, Python winerror 6 the handle is invalid python 3.4, Python 3.3, Python 2.7 process Status: open Resolution: Dependencies: Superseder: Assigned To: Nosy List: BreamoreBoy,
Error 6 The Handle Is Invalid Windows 7
Weird, amaury.forgeotdarc, benjamin.peterson, borisompol, chn, denversc, georg.brandl, jmfauth, kevinwatters, terry.reedy, tlesher, trentm, twhitema Priority: normal Keywords: Created on 2008-09-18 23:07 by twhitema, last changed 2015-06-22 17:13 by
Oserror: [winerror 6] The Handle Is Invalid Python
borisompol. Messages (22) msg73408 - (view) Author: Todd Whiteman (twhitema) Date: 2008-09-18 23:07 I'm getting a 'The handle is invalid' error when using subprocess.Popen in Python 2.5 (and 2.6). If any of the stdio handles are somehow invalid or not real io handles (fd is not 0, 1 or 2), and you are python selenium oserror: [winerror 6] the handle is invalid not telling subprocess to PIPE all of the handles, then subprocess throws the following exception. The easiest way to reproduce this is using run PythonWin from a Windows Command Prompt: C:\Python\Lib\site-packages\pythonwin\Pythonwin.exe and then use the following 2 subprocess code lines below: import subprocess p = subprocess.Popen(["python", "-c", "print 32"], stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE) Traceback (most recent call last): File "
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this
Winerror 6 The Handle Is Invalid Subprocess
site About Us Learn more about Stack Overflow the company Business Learn more error 6 the handle is invalid services about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x error 6 the handle is invalid sharepoint search Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Subprocess Popen https://bugs.python.org/issue3905 not working with pythonw.exe up vote 9 down vote favorite 3 I want to be able to get the contents of stdout and stderr when I run the following script on windows using pythonw.exe: import subprocess import sys import os import string import time tmpdir = 'c:/temp' cmd = 'dir c:' tmpfile = "tmp_%f" % (time.time()) tmpfile = os.path.normpath(os.path.join(tmpdir,tmpfile)) tmpfile2 = tmpfile+".bat" tmpfile3 = tmpfile+".txt" http://stackoverflow.com/questions/10290990/subprocess-popen-not-working-with-pythonw-exe fa = open(tmpfile2,'w') fa.write("@ECHO OFF > NUL\n") fa.write('call '+cmd+"\n") fa.close() wcmd = [] wcmd.append(tmpfile2) startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW fb = open(tmpfile3,'w') fb.write("\n") fb.write(tmpfile2+"\n") try: procval = subprocess.Popen(wcmd, startupinfo=startupinfo, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate() fb.write(str(procval)+"\n") fb.write("Sucess") fb.close() except: fb.write(str(procval)+"\n") fb.write("Failure") fb.close() When I execute it using python.exe I get the expected output. When I run it using pythonw.exe I end up on the exception side. If I run the popen with just the command and the startupinfo flags the command will successfully complete but no access to the data in the child processs. Everything that I read stated that this should work but must be missing something. Any help would be greatly appreciated. Thanks, Randy python subprocess share|improve this question edited Apr 24 '12 at 5:50 Andy 21k1167113 asked Apr 24 '12 at 2:26 user1352650 462 Did you happen to log the exception info? –jdi Apr 24 '12 at 6:04 I have tried but not successfull. This is easy enought to replicate so any ideas on how to get the exception info and will give it a shot –user1352650 Apr 25 '12 at 2:22 I dont understand
question and get tips & solutions from a community of 418,626 IT Pros & Developers. It's quick https://bytes.com/topic/python/answers/634409-subprocess-handle-invalid-error & easy. subprocess "handle is invalid" error P: n/a Grant Edwards I'm trying to use the py-gnuplot module on windows, and have been unable to get it to work reliably under Win2K and WinXP. By default, it uses popen(gnuplotcmd,'w'), but in some situations that consistently gets an "invalid operand" IOError when write() is called on the pipe. error 6 So I switched to subprocess. It works fine when executed "normally" (e.g. "python progname.py"), but when bundled by py2exe, it always does this: Traceback (most recent call last): File "surfedit.py", line 28, in ? File "Gnuplot\_Gnuplot.pyc", line 178, in __init__ File "Gnuplot\gp_win32.pyc", line 117, in __init__ File "subprocess.pyc", line 533, in __init__ File "subprocess.pyc", line 607, in the handle is _get_handles File "subprocess.pyc", line 634, in _make_inheritable WindowsError: [Errno 6] The handle is invalid How does one troubleshoot errors that happen three layers deep in the subprocess module? -- Grant Edwards grante Yow! I'm a fuschia bowling at ball somewhere in Brittany visi.com Apr 18 '07 #1 Post Reply Share this Question 5 Replies P: n/a Erik Johnson "Grant Edwards"