为什么我的程序可以使用 .py 扩展名而不是 .pyw 扩展名? [英] Why does my program work with a .py extension but not with a .pyw extension?

查看:34
本文介绍了为什么我的程序可以使用 .py 扩展名而不是 .pyw 扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,可以将 Google Earth .kml/.kmz 文件转换为 shapefile,使用 Tkinter 编写的简单 GUI 界面.

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

我的问题是它在 .py 扩展名下工作正常,但是当使用 .pyw 扩展名保存时,它在读取我的 .kml 文件.

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.

没有错误消息,也不会崩溃.GUI 启动正常,等等,但它只是停止并且总是在大致相同的位置.我使用的是 Python 2.5,结果与 Python 2.7 相同.

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?

推荐答案

.pyw 文件的运行方式与 .py 文件不同——它们与不同的解释器 pythonw.exe 相关联 而不是 python.exe,后者没有与之关联的控制台.

.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.

如果没有看到确切的脚本,我们无法确切地知道导致 pythonw 问题的原因.

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

这篇关于为什么我的程序可以使用 .py 扩展名而不是 .pyw 扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆