Open
Description
Version
1.49.0
Steps to reproduce
Code: test.py
from playwright.sync_api import sync_playwright
ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=True)
context = browser.new_context(user_agent=ua)
page = context.new_page()
page.goto('https://www.google.com/')
page.screenshot(path=f'test.png')
browser.close()
env: Raspberry Pi
- python -m venv test
- export PLAYWRIGHT_BROWSERS_PATH=0
- python -m playwright install
- python test.py -> works
- pyinstaller -F test.py
- ./dist/test
Expected behavior
no error
Actual behavior
Traceback (most recent call last):
File "test.py", line 10, in <module>
page.goto('https://www.baidu.com/')
File "playwright/sync_api/_generated.py", line 9006, in goto
File "playwright/_impl/_sync_base.py", line 115, in _sync
File "playwright/_impl/_page.py", line 551, in goto
File "playwright/_impl/_frame.py", line 145, in goto
File "playwright/_impl/_connection.py", line 61, in send
File "playwright/_impl/_connection.py", line 528, in wrap_api_call
playwright._impl._errors.TargetClosedError: Page.goto: Target page, context or browser has been closed
Call log:
- navigating to "https://www.google.com/", waiting until "load"
[PYI-32348:ERROR] Failed to execute script 'test' due to unhandled exception!
Additional context
If execute the source code directly, the result is correct, but after packaging with pyinstaller, it is not correct.
The same code packaged under Windows, the results are also correct.
Environment
- Operating System: [Debian 6.1.31]
- CPU: [arm64]
- Browser: [chromium_headless_shell-1148]
- Python Version: [3.9.2]
- Other info: