I have written a small program in python using pyppeteer. It runs fine on my Windows computer, but when I tried running it on a Unix-based system it did not work. Here's a minimal reproducible example:
import asyncio
from pyppeteer import launch
async def main():
browser = await launch(headless=True)
page = await browser.newPage()
await page.goto('http://www.example.com')
print(await page.content(), flush=True)
asyncio.get_event_loop().run_until_complete(main())
On Windows it runs as expected and returns a HTML page. On Unix, I get this error after about 35 seconds of nothing happening:
Traceback (most recent call last):
File "pyppeteerTest.py", line 10, in <module>
asyncio.get_event_loop().run_until_complete(main())
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "pyppeteerTest.py", line 5, in main
browser = await launch(headless=True)
File "/home/thatcoolcoder/.local/lib/python3.6/site-packages/pyppeteer/launcher.py", line 306, in launch
return await Launcher(options, **kwargs).launch()
File "/home/thatcoolcoder/.local/lib/python3.6/site-packages/pyppeteer/launcher.py", line 167, in launch
self.browserWSEndpoint = get_ws_endpoint(self.url)
File "/home/thatcoolcoder/.local/lib/python3.6/site-packages/pyppeteer/launcher.py", line 226, in get_ws_endpoint
raise BrowserError('Browser closed unexpectedly:\n')
pyppeteer.errors.BrowserError: Browser closed unexpectedly:
I am running python 3.8.2 on Windows and python 3.6.9 on Unix but I doubt that is the problem. I've tried the fixes suggested in the comments on this answer but that didn't change anything.