1.下载PyInstaller 。地址http://www.pyinstaller.org/
2.解压 ,将需要打包的py程序放到pyinstaller目录下
3.pyinstaller依赖一些windows的组件,需要到http://sourceforge.net/projects/pywin32/ 下载相应python的版本,
例如:python2.7的32位版:pywin32-218.win32-py2.7.exe
放到pyinstaller目录下
4.测试pyinstall安装是否正确
进入pyinstaller目录,试运行看看是否安装正确。
以下是运行屏幕:
C:\>cd c:\pyinstaller
C:\pyinstaller>c:\python27\python pyinstaller.py
Error: PyInstaller for Python 2.6+ on Windows needs pywin32.
Please install from http://sourceforge.net/projects/pywin32/
#上面的错误提示安装pywin32-218.win32-py2.7.exe。
C:\pyinstaller>c:\python27\python pyinstaller.py
Usage: python pyinstaller.py [opts] <scriptname> [ <scriptname> ...] | <specfile>
pyinstaller.py: error: Requires at least one scriptname file or exactly one .spec-file
# 以上信息表示可以开展工作了。
5.开始打包
C:\pyinstaller>c:\python27\python pyinstaller.py --console --onefile convert.py
....
会生成convert目录,在build下生成convert.exe
提示:
如果出现Error loading Python DLL: E:\download\PYINST~1.1\CONVER~1\build\CONVER~1\python2
7.dll (error code 126)错误
搜索系统中的python27.dll,放到convert.exe目录下或者window