详解pyinstaller硒python3 chrome打包问题

  

今天打包硒一个简单的请求,打完包本机运行exe没有问题,换台机器就闪退,非常蛋疼找了半天原因。

  

下面简述下,防止踩坑,如果闪退十有八九是浏览器版本跟浏览器插件对不上。

  

首先安装pyinstaller

        pip安装pyinstaller      

然后进入要打包的py文件目录

  

详解pyinstaller硒python3 chrome打包问题

  

然后pyinstaller tomcat.py

  

这种打包方式有很多文件,不太美观

  

第二种打包方式:pyinstaller - f tomcat.py

  

详解pyinstaller硒python3 chrome打包问题

  

下面就是重点,我之前忘记把浏览器插件复制到. exe文件目录所以一直闪退,另外插件版本必须跟浏览器一直。

  

详解pyinstaller硒python3 chrome打包问题

  

运行效果:

  

详解pyinstaller硒python3 chrome打包问题

  

但是会有医生黑窗口,没有隐藏chromedriver

  

详解pyinstaller硒python3 chrome打包问题

  

修改service.py第75行左右添加creationflags=134217728

  

详解pyinstaller硒python3 chrome打包问题

  

然后打包时添加pyinstaller - f - w tomcat.py

  

详解pyinstaller硒python3 chrome打包问题

  

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

详解pyinstaller硒python3 chrome打包问题