linux 无桌面版pyppeteer执行js时报错

Traceback (most recent call last):
File "test1.py", line 57, in <module>
asyncio.get_event_loop().run_until_complete(main())
File "/usr/lib64/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "test1.py", line 35, in main
browser = await launch(headless=True,options={'args': ['--no-sandbox']})
File "/usr/local/lib/python3.6/site-packages/pyppeteer/launcher.py", line 307, in launch
return await Launcher(options, **kwargs).launch()
File "/usr/local/lib/python3.6/site-packages/pyppeteer/launcher.py", line 168, in launch
self.browserWSEndpoint = get_ws_endpoint(self.url)
File "/usr/local/lib/python3.6/site-packages/pyppeteer/launcher.py", line 227, in get_ws_endpoint
raise BrowserError('Browser closed unexpectedly:\n')
pyppeteer.errors.BrowserError: Browser closed unexpectedly:

原因:很大可能是环境问题,缺少依赖导致的

解决办法是:

yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y

  

posted @ 2022-01-20 16:35  飞扬92  阅读(868)  评论(0编辑  收藏  举报