- 想做一个浏览器自动化的小插件,本地安装了
Playwright,测试可以正常打开浏览器自动化。 - 但是在使用
PyInstaller将Python代码打包成app/exe后,打开应用程序报错:
playwright._impl._api_types.Error: Executable doesn't exist at /Users/dengzemiao/Desktop/Project/python/dist/main/playwright/driver/package/.local-browsers/chromium-1033/chrome-mac/Chromium.app/Contents/MacOS/Chromium ╔════════════════════════════════════════════════════════════╗ ║ Looks like Playwright was just installed or updated. ║ ║ Please run the following command to download new browsers: ║ ║ ║ ║ playwright install ║ ║ ║ ║ <3 Playwright Team ║ ╚════════════════════════════════════════════════════════════╝ • 1 • 2 • 3 • 4 • 5 • 6 • 7 • 8 • 9 • 10 • 11 • 12 • 13 • 14 • 15 • 16 • 17
- 原因是:
Playwright没有被打到包内,解决方案
# 重新安装一下(chromium 是其中一个浏览器插件,看自己用什么就装什么) # Expecting one of: chromium, chrome, chrome-beta, msedge, msedge-beta, msedge-dev, firefox, webkit $ PLAYWRIGHT_BROWSERS_PATH=0 playwright install chromium # 然后再次打包 pyinstaller -F main.py