使用Ubuntu 22运行Ubuntu 22(jammy)容器,即可运行。使用 Ubuntu 20 运行它不会工作并导致此问题。如果您遇到此问题,请投票,这有助于我们确定优先级。
语境:
- 剧作家版本:1.23.0
- 操作系统:Linux
- Python版本:3.10
- 浏览器:Webkit
代码片段 pw.py
import asyncio
from playwright.async_api import async_playwright
async def run():
async with async_playwright() as playwright:
await playwright.webkit.launch(headless=True)
if __name__ == "__main__":
asyncio.run(run())
Dockerfile
FROM snakepacker/python:3.10
RUN apt-install python3-pip && \
pip install playwright==1.23.0 && \
playwright install --with-deps webkit
ADD ./pw.py pw.py
CMD python3 pw.py
描述错误
剧作家启动 webkit 超时
docker build -t test-pw . && docker run test-pw
Traceback (most recent call last):
File "//pw.py", line 11, in <module>
asyncio.run(run())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "//pw.py", line 8, in run
await playwright.webkit.launch(headless=True)
File "/usr/local/lib/python3.10/dist-packages/playwright/async_api/_generated.py", line 11399, in launch
await self._impl_obj.launch(
File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_browser_type.py", line 93, in launch
Browser, from_channel(await self._channel.send("launch", params))
File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_connection.py", line 43, in send
return await self._connection.wrap_api_call(
File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_connection.py", line 370, in _
return await result
File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_connection.py", line 78, in inner_send
result = next(iter(done)).result()
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
<launching> /root/.cache/ms-playwright/webkit-1668/pw_run.sh --inspector-pipe --headless --no-startup-window
<launched> pid=440
============================================================