playwright and pyinstaller
1.pycharm创建一个虚拟环境
playwright
启动chrome加载用户数据(非无痕模式)
playwright 启动无痕模式
#查看playwright内置浏览器安装路径
playwright install --dry-run
########### 打包exe 步骤###########
1.pycharm中创建虚拟环境
2.安装相关依赖
pip install playwright -i https://mirrors.aliyun.com/pypi/simple/
注意默认使用 python -m playwright install 安装chromium、frefox、webkit。
3. 设置环境变量,指定playwright浏览器安装目录
set PLAYWRIGHT_BROWSERS_PATH=绝对路径
set PLAYWRIGHT_BROWSERS_PATH=D:\code\yingdao\venv\Lib\site-packages\playwright\driver\pw-browsers
playwright install chromium
卸载安装的浏览器:playwright uninstall chromium
4. 安装打包工具
pip install pyinstaller
5.打包
pyinstaller -F main.py -i favicon.ico
#添加依赖
pyinstaller --add-data "dependency_folder;dependency_folder" your_script.py
pyinstaller --hidden-import your_module your_script.py
pyinstaller --add-data "utils;utils" run.py
pyinstaller --hidden-import utils run.py
-w 来让程序运行时不显示
pyinstaller --add-data "resources;resources" run.py