Python 2.7.16 pyinstaller3.0 生成exe可执行文件

背景:

本人用python2.7+pyqt4 写了一个记录仪器log的带界面的小程序,要拿到客户电脑上用,必须要打包成可执行文件才行!

========================================================

找方法:

网上搜了一下很简单,pyinstaller -F xxx.py 就能生成梦寐以求得可执行文件了

第一步:打开dos,直接输入命令 "pip install pyinstaller" 安装 pyinstaller,但事与愿违直接报错,

ERROR: Command errored out with exit status 1: 'c:python27amd64python.exe' 'c:python27amd64libsite-packagespip\_vendorpep517\_in_process.py' get_requires_for_build_wheel 'c:userswelu1appdatalocal emp mphbreil' Check the logs for full command output.(什么鬼完全不晓得啥意思)

上网搜了好久,说是新版本得pyinstaller(目前是4.0版本)与python2.7不兼容了,只能安装pyinstaller 3.0版本,那只能手动下载安装包文件了,下载地址:https://pypi.org/project/pyinstaller/3.0/#files

下载完成后是  PyInstaller-3.0.tar.gz 文件,解压缩后通过cmd进入到 C:...distPyInstaller-3.0目录下, 执行 python setup.py install 命令就可以安装了

=============================================

结果:

大功告成,可以打包了,通过cmd进入到需要打包的文件目录,执行命令 pyinstaller -F xxx.py,在当前目录的dist目录下成功生成 exe文件,双击可以正常运行

但是有一个问题,总是有个黑色框一起出现,很难看,于是又查找方法,解决方法是打包时增加参数-w:pyinstaller -F -w xxx.py 

原文地址:https://www.cnblogs.com/njuptlwh/p/13875415.html