the error happens because jupyter always runs an asyncio event loop, which conflicts with Playwright’s Sync API. to fix it, the cleanest approach is to switch to Playwright’s Async API (from playwright.async_api import async_playwright) and call your function with await in the notebook. If you want keep the Sync API version, you can instead run it inside a separate thread (so it’s outside Jupyter’s loop). In vs code, the “module not found” issue comes from using a different Python environment than your notebook: make sure both point to the same interpreter and install Playwright with python -m pip install playwright followed by python -m playwright install.