从 python 脚本创建可执行文件 [英] Creating an executable file from python script
问题描述
我使用 python 和 wxpython 创建了一个 GUI 程序.现在可以将其转换为可执行文件.在过去的两天里,我按照 py2exe 的各种说明进行了尝试.命令提示符的所有说明均参考旧版本的 Windows,我使用的是 Windows 7.我以前从未使用过命令提示符,因为我还是编程新手.py2exe 是创建可执行文件的最佳方式还是有更好的选择?
I have created a GUI program using python and wxpython. It is now ready to be turned into an executable file. I have tried for the last two days following various instructions from py2exe. All instructions for Command Prompt refer to older versions of windows and I'm using windows 7. I have never used Command Prompt before as I'm still new to programming. Is py2exe going to best way to create an executable file or is there a better option?
我已按照有关创建 setup.py 文件的说明进行操作,内容如下:
I have followed instructions on creating a setup.py file and it reads:
from distutils.core import setup
import py2exe
setup(windows = ["Core.py"])
当我在命令提示符中输入命令时:
When I enter the command in Command Prompt:
C:\Python27\Cylinderdrawer\python setup.py py2exe
我得到以下信息:
'C:\Python27\Cylinderdrawer\python' is not recognized as an internal or eternal command, operable program or batch file
推荐答案
有两个以上的选项.您可以使用 py2exe、PyInstaller、cx_freeze 和 bb_freeze.我喜欢使用 GUI2Exe 包装器脚本,它包装了所有这些以及 py2app(适用于 Mac),因为它使调整设置变得轻而易举.
There are more than two options. You can use py2exe, PyInstaller, cx_freeze and bb_freeze. I enjoy using the GUI2Exe wrapper script that wraps all of these plus py2app (for Macs) as it makes tweaking the settings a breeze.
据我所知,cx_freeze、PyInstaller 和 bb_freeze 拥有最新版本,py2exe 是 2008 年的最后一个版本.
As far as I can tell, cx_freeze, PyInstaller and bb_freeze have the newest releases with py2exe's last release in 2008.
至于您的问题,听起来您的系统路径上没有 Python.尝试输入python的完整路径.像这样:
As for your issue, it sounds like you don't have Python on your system path. Try typing out the full path to your python instead. Something like this:
c:\python27\python.exe setup.py py2exe
我不知道Cylinderdrawer"是什么,但这不是 Windows 上 Python 可执行文件的标准位置.
I don't know what "Cylinderdrawer" is, but that is NOT a standard location for the Python executable on Windows.
另见:
这篇关于从 python 脚本创建可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!