     [Answers](https://scrapfly.io/blog)   /  [jupyter](https://scrapfly.io/blog/tag/jupyter)   /  [How to run Playwright in Jupyter notebooks?](https://scrapfly.io/blog/answers/playwright-in-ipython)   # How to run Playwright in Jupyter notebooks?

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) Aug 27, 2026 3 min read [\#jupyter](https://scrapfly.io/blog/tag/jupyter) [\#playwright](https://scrapfly.io/blog/tag/playwright) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fplaywright-in-ipython "Share on LinkedIn") [  ](https://x.com/intent/tweet?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fplaywright-in-ipython&text=How%20to%20run%20Playwright%20in%20Jupyter%20notebooks%3F "Share on X") [  ](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fplaywright-in-ipython "Share on Facebook")    

 

 

Summarize this article with

 [  ](https://chat.openai.com/?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fplaywright-in-ipython) [  ](https://claude.ai/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fplaywright-in-ipython) [  ](https://x.com/i/grok?text=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fplaywright-in-ipython) [  ](https://www.perplexity.ai/search/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fplaywright-in-ipython) [  ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fplaywright-in-ipython) 



The Playwright package is a popular web browser automation tool in Python, which can be run in Jupyter notebooks for quick web scraping scripts. However, since Jupyter notebooks runs its own asyncio loops, we cannot start the synchronous playwright client: :

python```python
# in Jupyter:

from playwright.sync_api import sync_playwright
playwright = sync_playwright().start()

"""
Error: It looks like you are using Playwright Sync API inside the asyncio loop.
Please use the Async API instead.
"""
```



Depending on how the traceback is surfaced, the same failure also appears fully qualified:

```
playwright._impl._errors.Error: It looks like you are using Playwright Sync API inside the asyncio loop.
Please use the Async API instead.
```



The reason behind the above error is that there's an already running event loop. To use Playwright in Jupyter notebooks, we should explicitly use the asynchronous Playwright client using the following code:

python```python
# in Jupyter:

import nest_asyncio
import asyncio
from playwright.async_api import async_playwright
import atexit

# Allow nested event loops
nest_asyncio.apply()

async def main():
    pw = await async_playwright().start()
    browser = await pw.chromium.launch(headless=True)
    page = await browser.new_page()

    # All methods are async (use the "await" keyword)
    await page.goto("https://web-scraping.dev")
    src = await page.content()
    print(src)
    # Function to close browser and stop Playwright
    async def shutdown_playwright():
        await browser.close()
        await pw.stop()

    # Register shutdown hook for when the program exits
    atexit.register(lambda: asyncio.run(shutdown_playwright()))

# Run the async main function
await main()  # Use await directly instead of asyncio.run()
```



Here, we use playwright's async API and wrap it to the `main` function. Then, we execute in a nested asynchronous event loop using `nest_asyncio`. Note that the above snippet allows running Playwright in Google Colab since it shares the same concept as Jupyter notebooks.

## NotImplementedError on Windows

On Windows the same notebook can fail with a different traceback, one ending in `NotImplementedError` raised from `asyncio.create_subprocess_exec`. Playwright starts its driver as a subprocess, and `SelectorEventLoop` does not implement subprocess support on Windows. The asyncio documentation lists the limitation directly: `loop.subprocess_exec()` and `loop.subprocess_shell()` are not implemented on that loop.

`nest_asyncio` does not fix this one. It lets a nested loop run inside an existing loop, which is what unblocks the async example above, but it cannot add subprocess support to a loop that does not have it.

Since Python 3.8 `ProactorEventLoop` has been the default on Windows, so a plain script usually works. A notebook kernel may still be running a selector loop. Set the policy before Playwright starts, and restart the kernel first, because the policy applies when the loop is created rather than retroactively:

python```python
import asyncio

asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
```



For further details on web scraping with Playwright, refer to our dedicated guide.

[Web Scraping With Playwright in 2026: A Python GuideScrape JavaScript-rendered pages with Playwright and Python in 2026: locators, waiting, request interception, resource blocking, and concurrency.](https://scrapfly.io/blog/posts/web-scraping-with-playwright-and-python)



 

   [  Add as a preferred source ](https://google.com/preferences/source?q=scrapfly.io) Table of Contents















 

  Table of Contents- [NotImplementedError on Windows](#notimplementederror-on-windows)
 
    Join the Newsletter  Get monthly web scraping insights 

 

  



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? Get our newsletter instead. 

 

 ## Related Articles

 [     

 blocking 

### 5 Tools to Scrape Without Blocking and How it All Works

Tutorial on how to avoid web scraper blocking. What is javascript and TLS (JA3) fingerprinting and what role request hea...

 

 ](https://scrapfly.io/blog/posts/how-to-scrape-without-getting-blocked-tutorial) [     

 api headless-browser 

### Best Browser Automation Tools in 2026

Compare managed execution, open-source frameworks, AI agents, and no-code/RPA by protocol, state, protected-site support...

 

 ](https://scrapfly.io/blog/posts/best-browser-automation-tools) [     

 python blocking 

### 9 Mechanisms to Check When Your Scrapy Spider Gets Blocked in 2026

Diagnostic walkthrough for a blocked Scrapy spider, covering IP reputation, rate shape, cookie and session state, header...

 

 ](https://scrapfly.io/blog/posts/why-scrapy-spider-gets-blocked) 

  ## Related Questions

- [ Q How to Solve the cURL (60) Error When Using Proxy? ](https://scrapfly.io/blog/answers/how-to-solve-the-curl-60-error-when-proxy)
- [ Q How to count selections in XPath and why? ](https://scrapfly.io/blog/answers/how-to-count-selectors-in-xpath-and-why)
- [ Q How to scroll to the bottom of the page with Playwright? ](https://scrapfly.io/blog/answers/how-to-scroll-to-the-bottom-with-playwright)
- [ Q How to download a file with Playwright and Python? ](https://scrapfly.io/blog/answers/how-to-download-file-with-playwright)
 
  



   



 Run headless browsers at scale, **1,000 free credits** [Start Free](https://scrapfly.io/register)