playwright-python: [Bug]: AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'

Playwright version

1.16.1

Operating system

Windows 10

What browsers are you seeing the problem on?

No response

Other information

python 3.10.0

What happened? / Describe the bug

I see AttributeError sometimes when I run playwright.

Code snippet to reproduce your bug

from playwright.sync_api import sync_playwright

for i in range(10000):
    print(i)
    with sync_playwright() as p:
        pass

Relevant log output

Traceback (most recent call last):
  File "...\scratches\scratch_1.py", line 4, in <module>
    print(i)
  File "...\venv\lib\site-packages\playwright\sync_api\_context_manager.py", line 71, in __enter__
    playwright = self._playwright
AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 21 (3 by maintainers)

Most upvoted comments

Closing since Playwright does not support Windows 7 or Windows Server 2008. Both versions are end of life and not supported anymore (security updates by Microsoft as well).

@mxschmitt The op was windows 10, not 7

i followed the official example

from playwright.sync_api import sync_playwright
with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("http://playwright.dev")
    print(page.title())
    browser.close()

and i got this bug:

Node.js is only supported on Windows 8.1, Windows Server 2012 R2, or higher.
Setting the NODE_SKIP_PLATFORM_CHECK environment variable to 1 skips this
check, but Node.js might not execute correctly. Any issues encountered on
unsupported platforms will not be fixed.Traceback (most recent call last):

AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'
Task was destroyed but it is pending!
task: <Task pending name='Task-3' coro=<Connection.run.<locals>.init() running at D:\python\py_projects\police_helper\.venv\lib\site-packages\playwright\_impl\_connection.py:179> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x0000000002678B20>()]>>

platform: windows 7 nodejs v13.14.0 playwright python 1.17.0 python 3.8.10

@phoenixor I’m running into this same issue, were you able to fix it/find a workaround?