OSError when running puppeteer on raspberry pi

Viewed 1313

I am trying to make my RP a server for some web automation tasks so I installed python 3.7 and pypputeer (Python's version for Googlel's puppeteer). The problem is that my code that run smoothly on my OSX gives me the following error on the PI:

    Traceback (most recent call last):
  File "main.py", line 45, in <module>
    asyncio.get_event_loop().run_until_complete(main())
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete
    return future.result()
  File "main.py", line 16, in main
    browser = await launch(headless=True)
  File "/usr/local/lib/python3.7/site-packages/pyppeteer/launcher.py", line 311, in launch
    return await Launcher(options, **kwargs).launch()
  File "/usr/local/lib/python3.7/site-packages/pyppeteer/launcher.py", line 169, in launch
    **options,
  File "/usr/local/lib/python3.7/subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.7/subprocess.py", line 1499, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/pi/.local/share/pyppeteer/local-chromium/575458/chrome-linux/chrome'

The code only starts chromium in headless mode:

async def main():
    browser = await launch(headless=True)
    page = await browser.newPage()
    await page.goto(URL_FOR_SCRAPING)

asyncio.get_event_loop().run_until_complete(main())

I tried to install all the Debian dependencies from here and also make pypputeer install chromium again like it does at first time. but nothing seems to solve this error. There is also this Github post that doens't seem to be helpful. Does anyone know what can be done?

1 Answers

Apparently the solution was to redirect chromium path in the code to some version of chromium you know is working. so

whereis chromium-browser

and then:

browser = await launch(headless=True, executablePath='/usr/bin/chromium-browser') # where your chromium was, in my case /usr/bin/...
Related