Why does sync_playwright().start() hang in my Python script, and how can I fix it?

I’m trying to use Playwright in Python with the synchronous API. My script looks like this:

from playwright.sync_api import sync_playwright

print("debug1")
p = sync_playwright().start()
print("debug2")
browser = p.firefox.launch(headless=False)
page = browser.new_page()
page.goto("http://whatsmyuseragent.org/")
page.screenshot(path="example.png")
browser.close()

The program prints debug1 but then hangs indefinitely on sync_playwright().start(). I’ve tried switching browsers and using headless mode, but the issue persists.

Qa testing tools