mherrmann / helium

Lighter web automation for Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chromedriver unexpectedly exited. Status code was: 127

VladoPortos opened this issue · comments

Anybody tried to run this in aws lambda function ?

For the life of me, I can't get it to work…

I have super simple lambda function, that runs python 3.9 ( same issue in 3.8 )
In requirements.txt there is just helium, it will build and pull all needed packages.

Then I need to change chromedriver to executable, cause first it complained about that...

The function basically does only this:

from helium import *

    start_chrome(headless=True)
    start_chrome('google.com', headless=True)

But it always fails with:

/var/task/selenium/webdriver/firefox/firefox_profile.py:208: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if setting is None or setting is '':
[ERROR] WebDriverException: Message: Service /var/task/helium/_impl/webdrivers/linux/chromedriver unexpectedly exited. Status code was: 127
    raise WebDriverException(bdriver/common/service.py", line 109, in assert_process_still_running
{"errorMessage": "Message: Service /var/task/helium/_impl/webdrivers/linux/chromedriver unexpectedly exited. Status code was: 127\n", "errorType": "WebDriverException", "requestId": "2aa16ca2-06ba-4b94-849f-55267956b990", "stackTrace": ["  File \"/var/task/app.py\", line 11, in lambda_handler\n    start_chrome(headless=True)\n", "  File \"/var/task/helium/__init__.py\", line 76, in start_chrome\n    return _get_api_impl().start_chrome_impl(\n", "  File \"/var/task/helium/_impl/__init__.py\", line 101, in start_chrome_impl\n    self._start_chrome_driver(headless, maximize, options, capabilities)\n", "  File \"/var/task/helium/_impl/__init__.py\", line 110, in _start_chrome_driver\n    result = Chrome(\n", "  File \"/var/task/selenium/webdriver/chrome/webdriver.py\", line 73, in __init__\n    self.service.start()\n", "  File \"/var/task/selenium/webdriver/common/service.py\", line 98, in start\n    self.assert_process_still_running()\n", "  File \"/var/task/selenium/webdriver/common/service.py\", line 109, in assert_process_still_running\n    raise WebDriverException(\n"]}END RequestId: 2aa16ca2-06ba-4b94-849f-55267956b990

This seems more like an issue with selenium running on aws rather than with helium, since it shows that webdriver cannot start.
Have you tried running only with selenium installed and see if the driver opens up?

I think you are right, I have tried with selenium and chromedriver and the same result,

I'm still trying to get this working... I'm using the https://github.com/shelfio/chrome-aws-lambda-layer as chromium browser layer. But to be honest it's my first try with lambda so half-time I do not know what I'm doing. :D

Ok so I spend so much time on this issue. :(
Result:
The normal python3.x container that is provided by Amazon for lambda is not capable of running chromium (missing dependencies) so even if you manage to stick in and layer on chromium-headless, driver, selenium it will end with Status code was: 127.
Solution
Use own container that you will build locally and push as whole to be the lambda function. I did not know that was even a thing, that you can augment the container itself. So I ended up basing the container of this: https://github.com/umihico/docker-selenium-lambda

I need to write all the steps down, for beginner with lambda there was almost no information about this anywhere on google...

Nice, please provide a link to your steps ( gist/ blog post / whatever you prefer). I'm also curious about how you did it.

@dntzbgh Here is my working solution, it requires running lambda as docker image but otherwise works fine. https://rpi4cluster.com/aws/lambda_selenium/