pyinstaller 打包 pytest+allure 自动化测试框架后运行报错,请高手帮忙指点下

1.程序运行正常,在使用pyinstaller打成 .exe可执行文件后,双击运行报如下错误:

Auto_Runner_Api_Main.exe 程序执行时报如下错误:

ERROR: usage: Auto_Runner_Api_Main.exe [options] [file_or_dir] [file_or_dir] [...]

Auto_Runner_Api_Main.exe: error: unrecognized arguments: --alluredir=\ApiTestReport --clean-alluredir

inifile: None

rootdir: C:\Users\oscar\eclipse-workspace\AutoRunner_ApiPlatform\src\dist


注:本机已按装allure-pytest插件,将参数'--alluredir=\ApiTestReport', '--clean-alluredir'去掉打包成exe可以正常运行,难道 allure_pytest 包没打进去吗

哪位大佬给指点下呢!感谢!

明显是执行时加的参数不正确,代码里重新改下接受的参数


报以上错误不是参数的问题,程序是可以正常执行的,使用的是pytest.main(['.\\ApiTestCase\\', '--alluredir=\ApiTestReport', '--clean-alluredir'])只是打包成 exe文件后报的错误 ,不清楚打包后可执行文件运行时为什么不识别,--alluredir 参数。

需要把所有的依赖文件都打包进exe中,打包时候加上-p添加依赖库搜索目录,不然你本地安装的跟exe环境搜索依赖包的位置不一致


allure_pytest 是默认安装在 python36\Lib\site-packages 包下的,pyinstaller默认也是能搜索到的,怕是有的库没打进去,然后在.spec 文件中手动增加了 pathex=['c:\\Python36\\Lib\\site=packages'] 在 hiddenimports=['allure_pytest','allure_pytest.plugin'..]等配置,也不管用用呢

方便的话我试试打包

要不我把.spec的文件贴出来,你帮忙指点下!其它的你需要什么代码我也贴给你,你看可以不!

你的打包命令是啥

pyinstaller -F Auto_Runner_Api_Main.spec