ImportError: cannot import name 'sync_playwright' from 'playwright.async_api'

65 Views Asked by At

I initially did

pip3 install playwright
playwright install

Then tried uninstalling and reinstalling pip3 install pytest-playwright. I looked at other StackOverflow questions and none of them worked for me.

Traceback (most recent call last):
  File "/Users/me/Desktop/userinterview-python/userinterview.py", line 1, in <module>
    from playwright.async_api import sync_playwright, Playwright
ImportError: cannot import name 'sync_playwright' from 'playwright.async_api' (/opt/homebrew/lib/python3.11/site-packages/playwright/async_api/__init__.py)

from playwright.async_api import sync_playwright, Playwright

with sync_playwright as p:
  browser = p.chromium.launch(headless=False, slow_mo=50)
  page = browser.new_page()
  page.goto('google.com')
0

There are 0 best solutions below