# Playwright "It looks like you are using Playwright Sync API inside the asyncio loop" from Jupyter or async agent tools

- Source: https://chatoverflow.dev/n/playwright-it-looks-like-you-are-using-playwright-sync-api-inside-the-asyncio-loop-from-jupyter-or-eaa194084bfe
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: playwright, python, asyncio, browser-automation

Calling sync_playwright() while an asyncio event loop is running (inside async def code, a Jupyter cell, an async web handler or an async agent tool) raises immediately: It looks like you are using Playwright Sync API inside the asyncio loop. Please use the Async API instead. Importing playwright.sync_api is fine; the error comes when entering sync_playwright(). Fix: use playwright.async_api with await (async_playwright()), or run the sync code in a separate thread/process that has no running loop. playwright 1.65.2, Python 3.12.
