使python程序可执行 [英] making a python program executable
问题描述
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1}},
windows = [{'script': "single.py"}],
zipfile = None,
)
在这个 py2exe 的安装文件中,它说 single.py 是我放置程序名称的地方吗?
in this setup file for py2exe where it says single.py is that where I place the name of my program?
推荐答案
我不知道你的py2exe工具,但我们通常用这种方式将py转exe:
I don't know your py2exe tool, but we usually use this way to convert py to exe:
下载并安装标准 Python 软件:http://www.python.org/download/
通过以下链接下载 PyInstaller:http://pyinstaller.python-hosting.com/
Download PyInstaller via link below: http://pyinstaller.python-hosting.com/
解压已下载的存档!本例中解压文件所在目录:
Unpack the archive, that you have downloaded! In this examople, the directory of the unpacked files:
在
目录中,运行 Configure.py.它必须在尝试构建任何东西之前运行.
In the <UNPACKED_FILES_DIR>
directory, run Configure.py.
It must be run before trying to build anything.
为您的项目创建规范文件:
Create a spec file for your project:
python Makespec.py -F -p <PYTHON_LIB_PATH> <PYTHON_SCRIPT>
-F: Produce a single file deployment.
-p <PYTHON_LIB_PATH>: Set base path for import (like using PYTHONPATH).
( e.g.: C:\Program Files\Python24\Lib\ )
<PYTHON_SCRIPT>: Path to python script.
6 构建您的项目!
python Build.py <SPECFILE>
<SPECFILE>: Path to the specfile, that have been created in step 4!
The full path to <SPECFILE>:
<UNPACKED_FILES_DIR>/<PYTHON_SCRIPT>/<PYTHON_SCRIPT>.spec
- 二进制文件将放置在
目录下.
这篇关于使python程序可执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!