python打包.exe程序
2022-06-04 本文已影响0人
测试_机器猫
win下面的.exe程序自动化完成完成好久了,今天才有时间写其中的知识点-2022.6.4,后面再用单独篇幅去介绍自己封装的自动化小框架,今天主要是记录python打包成.exe的小知识点
1、安装pyinstaller第三方库
pip install pyinstaller或者可以通过pycharm设置方式安装,如图所示

安装完成后,验证是否安装成功

备注:期间遇到了安装第三方库失败的情况,具体报错:
报错Try to run this command from the system terminal. Make sure that you use the correct version of 'pip’问题
原因:我安装的是python3.8 当前pip版本过高,不匹配,降低pip版本
解决:python -m pip install pip==20.2.4
2、打包要运行的程序文件
2.1需要进入到Scripts文件夹下面,因为pyinstaller在该文件夹下面
2.2 运行打包命令
pyinstaller -F -c -p D:\Users\zhang\PycharmProjects\BurnAuto\Lib\site-packages D:\Users\zhang\PycharmProjects\BurnAuto\BurnInTest.py
3、打包成功后,会在Scripts文件夹下dist文件夹里面生成可以运行exe的程序文件

4、上面把用到的库一起打包里面了,如果用到图片或者配置文件,直接放到和exe同一级目录里面就行了

具体参数如下:
