Skip to content

Incompatible: playwright and Jupyter #202

Closed
@maxhumber

Description

@maxhumber

It seems that playwright is incompatible with a Jupyter workflow...

[1] Input Cell:

from playwright import sync_playwright

playwright = sync_playwright().start()

Error:

---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)
<ipython-input-7-238c5383064b> in <module>
      1 from playwright import sync_playwright
      2 
----> 3 playwright = sync_playwright().start()

~/opt/miniconda3/lib/python3.8/site-packages/playwright/__init__.py in sync_playwright()
     25 
     26 def sync_playwright() -> SyncPlaywrightContextManager:
---> 27     return SyncPlaywrightContextManager()
     28 
     29 

~/opt/miniconda3/lib/python3.8/site-packages/playwright/main.py in __init__(self)
     81 class SyncPlaywrightContextManager:
     82     def __init__(self) -> None:
---> 83         self._connection = run_driver()
     84         self._playwright: SyncPlaywright
     85 

~/opt/miniconda3/lib/python3.8/site-packages/playwright/main.py in run_driver()
     75     loop = asyncio.get_event_loop()
     76     if loop.is_running():
---> 77         raise Error("Can only run one Playwright at a time.")
     78     return loop.run_until_complete(run_driver_async())
     79 

Error: Can only run one Playwright at a time.

Likely caused by the fact that Jupyter also uses the event_loop

Would really love to use Playwright with Jupyter!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions