4

我试图让我的 RP 成为一些网络自动化任务的服务器,所以我安装了python 3.7pypputeer Googlel 的 puppeteer 的 Python 版本)。问题是我在我的 OSX 上顺利运行的代码在 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'

该代码仅在无头模式下启动 chromium:

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())

我尝试从这里安装所有 Debian 依赖项,并pypputeer像第一次一样再次安装 chromium。但似乎没有什么可以解决这个错误。还有这个 Github 帖子似乎没有帮助。有谁知道可以做什么?

4

1 回答 1

4

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/...
于 2018-12-29T14:57:50.143 回答