1、设置系统环境变量
首先需要在系统变量(path)中添加python下的Scripts文件夹,例如(c:\Python27\Scripts;)
使用pip的时候需要设置系统环境变量,后面使用pyinstaller也需要。
2、安装Pyinstaller
安装方式有两种,
(1)利用pip快捷安装:
pyinstaller发布在Pypi上,所以可以利用pip快速安装
在cmd下Install PyInstaller from PyPI:
pip install pyinstaller
or pip install –upgrade pyinstaller
(2)下载安装包安装(pyinstaller官网)
下载安装包安装,cd到安装目录使用python setup.py install运行setup.py进行安装。
在cmd 中使用pyinstaller -v 查看版本号可以测试是否安装成功。
3、使用pyinstaller打包程序:
用一句话打包程序,要加上参数-F,将程序的用到的库全部打包成一个exe文件,输出一个优雅的绿色软件:
pyinstaller -F c:/../yourprogram.py
成功后会显示输出路径dist:
4767 INFO: Appending archive to EXE C:\Users\dell\dist\yourprogram.exe
这时候去对应的路径,找到你的那个exe吧~