Why does my program work with a .py extension but not with a .pyw extension?
Asked Answered
E

1

6

I have a script that converts Google Earth .kml / .kmz files to shapefiles with a simple GUI interface written in Tkinter.

My problem is that it works fine with a .py extension, but when saved out with a .pyw extension it stalls while reading my .kml files.

There are no error messages and it doesn't crash. The GUI launches OK, etc, but it just stops and always at about the same place. I'm using Python 2.5, and had the same results with Python 2.7.

Any ideas what could cause this?

Earhart answered 11/4, 2012 at 21:7 Comment(0)
B
8

.pyw files are run differently than .py files -- they are associated with a different interpreter, pythonw.exe instead of python.exe, which doesn't have a console associated with it.

According to some sources, including this old mailing list thread some operations don't work without a console.

Without seeing the exact script, we can't know exactly is causing the problem for pythonw.

Beera answered 11/4, 2012 at 21:20 Comment(3)
Thanks! I burned several hours this morning trying to find a work around, but I never could figure it out. What I suspect is there's a problem with using readline() with pythonw.exeEarhart
@Earhart It's almost certainly not readline. Do you use any system calls, Popen, anything like that? If you post your code, I'd be glad to take a look.Beera
I've run into problems like this in the past -- it's usually an output pipe filling up because there's no one to read from it. Some applications really, really expect a console to be there. If they keep sending data to standard output or standard error, eventually the pipe fills up (since nothing's consuming the data) and the process blocks waiting for some space to be available in the pipe.Quoth

© 2022 - 2024 — McMap. All rights reserved.