Tengo un código de Python que funciona correctamente cuando uso python.exe para ejecutarlo, pero falla si uso pythonw.exe.Python subprocess.call() falla al usar pythonw.exe
def runStuff(commandLine): outputFileName = 'somefile.txt' outputFile = open(outputFileName, "w") try: result = subprocess.call(commandLine, shell=True, stdout=outputFile) except: print 'Exception thrown:', str(sys.exc_info()[1]) myThread = threading.Thread(None, target=runStuff, commandLine=['whatever...']) myThread.start()
El mensaje que recibo es:
Exception thrown: [Error 6] The handle is invalid
Sin embargo, si no se especifica el parámetro 'stdout', subprocess.call() empieza bien.
Veo que pythonw.exe podría estar redireccionando la salida, pero no veo por qué estoy bloqueado para especificar stdout para un nuevo hilo.
Actualmente estoy teniendo el mismo problema, he hecho una gran aplicación con PyQt4 y no puedo obtener selenio para trabajar sin la consola. Por favor, dime cómo arreglar esto. https://stackoverflow.com/questions/46520823/selenium-dont-work-after-exporting-to-exe-in-windowed-mode-in-pyinstaller –