Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run selenium in AWS Lambda with Python 3.8 #295

Open
jiridj opened this issue Mar 17, 2021 · 4 comments
Open

Unable to run selenium in AWS Lambda with Python 3.8 #295

jiridj opened this issue Mar 17, 2021 · 4 comments

Comments

@jiridj
Copy link

jiridj commented Mar 17, 2021

Hi!

I'm having issues running headless chrome on AWS Lambda with the Python 3.8 runtime. I'm hoping you would have an idea why.

  • Chromedriver 87.0.4280.87 for linux64
  • Serverless Chrome v1.0.0-57 for amazon-linux-2

This is the exception I get, which according to StackOverflow typically points to incompatibilities between the two libraries above.

{
  "errorMessage": "Message: Service /opt/chromedriver unexpectedly exited. Status code was: 127\n",
  "errorType": "WebDriverException",
  "stackTrace": [
    "  File \"/var/task/serverless_sdk/__init__.py\", line 144, in wrapped_handler\n    return user_handler(event, context)\n",
    "  File \"/var/task/handler.py\", line 13, in scrape\n    driver = webdriver.Chrome('/opt/chromedriver', chrome_options=options)\n",
    "  File \"/opt/python/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py\", line 73, in __init__\n    self.service.start()\n",
    "  File \"/opt/python/lib/python3.8/site-packages/selenium/webdriver/common/service.py\", line 98, in start\n    self.assert_process_still_running()\n",
    "  File \"/opt/python/lib/python3.8/site-packages/selenium/webdriver/common/service.py\", line 109, in assert_process_still_running\n    raise WebDriverException(\n"
  ]
}

What would be the proper version of Chromedriver to run serverless chrome with Python 3.8?

Thanks!

@umihico
Copy link

umihico commented Apr 15, 2021

@jiridj
I use serverless-chrome with Python 3.8 in AWS Lambda. In my case, I needed to install dependencies, and installing the latest chrome solves the task. There must be multiple ways to install. My way was below.

you can see my Dockerfile here. https://github.com/umihico/docker-selenium-lambda

@jiridj
Copy link
Author

jiridj commented Apr 15, 2021

Thanks @umihico! This is very helpful!
I interpret your Dockerfile as using chromedriver with chrome, not using headless chrome. Do I read that right?

@umihico
Copy link

umihico commented Apr 15, 2021

@jiridj
I installed chrome but not run it. This function runs with adieuadieu's headless-chrome. I just install chrome to solve dependency problem.

@llilicheng4
Copy link

so did it work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants