【发布时间】:2013-12-11 17:48:06
【问题描述】:
我想为 Windows 平台生成我的 Python GUI 应用程序的可执行文件。
- 我正在使用两个 .py OO 脚本
- 第一个脚本 (processcls.py) 包含此标头:
from lxml import html
from urllib import urlopen
import os, re, sys, time
- 第二个脚本包含此标头:
from processcls import *
from Tkinter import *
import Queue, threading, tkFileDialog, ttk, tkMessageBox, win32clipboard
- 这是我的 py2exe 脚本。问题是我看不到任何创建的 GUI。所以我不清楚我在代码中的错误在哪里。
from distutils.core import setup
import py2exe
setup(
name='MyApplic',
author='amazon',
author_email='lepetit@sk.com',
windows=[
{
'script':"init.py",
'uac_info': "requireAdministrator","icon_resources": [(1, "favicon.ico")]
}
],
options=
{
'py2exe':{
'includes': ['lxml.etree', 'lxml._elementpath', 'gzip', 'processcls'],
'packages': ['lxml', 'urllib', 'Tkinter'],
'bundle_files': 1,
'compressed' : True
}
},
zipfile = None
)
有什么建议吗? 我使用 Tkinter 作为 GUI 语法和 Python 2.7
谢谢 米格罗
【问题讨论】:
-
关于将 tkinter 与 py2exe 结合使用还有其他几个问题。你检查过其中任何一个吗?此外,虽然这不能回答您的问题,但我建议您尝试使用PyInstaller。 py2exe 不再被积极维护,它的精神继承者 PyInstaller 更容易使用 IMO。
-
谢谢。事实上,还有一些关于 Tkinter 的其他问题,但不是 Tkinter+Py2exe,不是专门针对我遇到的问题。让我试试 PyInstaller,我会评论。
-
@Iguananaut - Py2exe 肯定仍在维护。 Thomas Heller 在 SourceForge 处理过这个问题,我知道一个更新正在进行中,其中包括(除其他外)对 64 位安装的 bundle_files 的支持。
-
@MigRome - 另外值得注意的是 - pyinstaller 每次启动程序都使用 2 次执行(提取到临时文件夹,运行提取的程序,清理临时文件夹)。根据您的程序所做的事情以及它是否会重复运行,这可能会导致严重磁盘开销。
-
运行
python setup.py py2exe时有没有报错?
标签: python python-2.7 user-interface tkinter py2exe