Skip to content

[BUG] could not use sync api inside jupyter notebook #480

@zhuoqiang

Description

@zhuoqiang
  • Python: 3.8
  • Playwright: 1.8.0a1
  • OS: MacOS Catalina

the following code failed to run in jupyter notebook envrionment

import playwright.sync_api
with playwright.sync_api.sync_playwright() as api:
    pass

it gives error

---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)
<ipython-input-19-af4d5d3f125f> in <module>
      1 import playwright.sync_api
----> 2 with playwright.sync_api.sync_playwright() as api:
      3     pass

python3.8/site-packages/playwright/sync_api/_context_manager.py in __enter__(self)
     65         self._connection.call_on_object_with_known_name("Playwright", callback_wrapper)
     66 
---> 67         dispatcher_fiber.switch()
     68         playwright = self._playwright
     69         playwright.stop = self.__exit__  # type: ignore

python3.8/site-packages/playwright/sync_api/_context_manager.py in greenlet_main()
     41 
     42             if loop.is_running():
---> 43                 raise Error(
     44                     """It looks like you are using Playwright Sync API inside the asyncio loop.
     45 Please use the Async API instead."""

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

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