Forums

pyppeteer error on PythonAnywhere, works locally

Hi all, I'm a paying customer and been using PythonAnywhere for a month or so now. It's a great platform, unfortunately, I'm running into this error when attempting to use pyppeteer. It works perfectly fine locally, any ideas what I can look into or how I can debug further?

    browser = await launch(headless=True)
  File "/home/sevens/discord-bots/my-env/lib/python3.9/site-packages/pyppeteer/launcher.py", line 307, in launch
    return await Launcher(options, **kwargs).launch()
  File "/home/sevens/discord-bots/my-env/lib/python3.9/site-packages/pyppeteer/launcher.py", line 168, in launch
    self.browserWSEndpoint = get_ws_endpoint(self.url)
  File "/home/sevens/discord-bots/my-env/lib/python3.9/site-packages/pyppeteer/launcher.py", line 227, in get_ws_endpoint
    raise BrowserError('Browser closed unexpectedly:\n')
pyppeteer.errors.BrowserError: Browser closed unexpectedly:

Can you run the code from https://help.pythonanywhere.com/pages/selenium/? How is the browser set up in your code?

EDIT: Also check if you are not starting multiple browser processes at once. Browser may crash because of the processes limit reached.

Had a look and this was solved using the --no-sandbox option. Still had an issue as I wanted to run this code using Firefox but I was told only Chromium binaries are installed. Was advised I could potentially install Firefox with geckodriver myself so will explore.