You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BUG]I have installed Python 3.10 environment with Anaconda and then installed Playwright. However, when activating the Playwright environment in the command prompt (powershell) and trying to run the playwright command, there is no response. #2228
Additionally, when running a Playwright demo script (demo.py), you encounter the following error:
(playwright) PS C:\Users\peng\git\playwright> python demo.py
Traceback (most recent call last):
File "C:\Users\peng\git\playwright\demo.py", line 3, in
with sync_playwright() as p:
File "C:\Users\peng.conda\envs\playwright\lib\site-packages\playwright\sync_api_context_manager.py", line 79, in enter
playwright = self._playwright
AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'
Task was destroyed but it is pending!
task: <Task pending name='Task-3' coro=<Connection.run..init() running at C:\Users\peng.conda\envs\playwright\lib\site-packages\playwright_impl_connection.py:273> wait_for= cb=[ProtocolCallback.init..cb() at C:\Users\peng.conda\envs\playwright\lib\site-packages\playwright_impl_connection.py:194]>
Future exception was never retrieved
future: <Future finished exception=Exception('Connection closed while reading from the driver')>
Exception: Connection closed while reading from the driver
Future exception was never retrieved
future: <Future finished exception=BrokenPipeError(32, '管道正在被关闭。', None, 232, None)>
Traceback (most recent call last):
File "C:\Users\peng.conda\envs\playwright\lib\asyncio\proactor_events.py", line 401, in _loop_writing
self._write_fut = self._loop._proactor.send(self._sock, data)
File "C:\Users\peng.conda\envs\playwright\lib\asyncio\windows_events.py", line 548, in send
ov.WriteFile(conn.fileno(), buf)
BrokenPipeError: [WinError 232] 管道正在被关闭。
Source code
from playwright.sync_api import Playwright,sync_playwright
with sync_playwright() as playwright:
browser = playwright.chromium.launch(channel='chrome', headless=False)
context = browser.new_context()
page = context.new_page()
page.goto('https://baidu.com')
page.wait_for_load_state('networkidle')
page.screenshot(path='example.png')
browser.close()