py2exe,问题
我正在尝试把一个 .py 文件转换成 .exe 文件。但是我得到了一些奇怪的输出。
输出:
usage: module1 [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: module1 --help [cmd1 cmd2 ...]
or: module1 --help-commands
or: module1 cmd --help
error: no commands supplied
我的代码:
from distutils.core import setup
import py2exe
setup(console=['newstyledemo.py'])
另外,完成后我在哪里可以找到这个 .exe 文件呢?我想把它放到一个闪存驱动器上,以便重新分发。
顺便说一下,我是在 Windows 7 上运行 Python 2.6。
1 个回答
1
使用 Gui2exe 是个聪明的选择,我用它来处理控制台和图形界面。
下面是我用过的一个脚本,效果还不错。
from distutils.core import setup
import py2exe
import sys
if len(sys.argv) == 1:
sys.argv.append("py2exe")
setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 3}},
zipfile = None,
## data_files = ['apple.jpg', 'cheese.jpg'],
#Your py-file can use windows or console
windows = [{"script": 'my.py'}])