我正在尝试在 Google Cloudrun 上部署我的抓取工具,但是出现以下错误。selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.at check_response (/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py:242)at execute (/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:321)at start_session (/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:252)at __init__ (/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:157)at __init__ (/usr/local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py:76)at scrape_refresher (/app/refresher_news_crawler.py:32)at run_crawlers (/app/main.py:30)at dispatch_request (/usr/local/lib/python3.8/site-packages/flask/app.py:1936)at full_dispatch_request (/usr/local/lib/python3.8/site-packages/flask/app.py:1950)at reraise (/usr/local/lib/python3.8/site-packages/flask/_compat.py:39)at handle_user_exception (/usr/local/lib/python3.8/site-packages/flask/app.py:1821)at wrapped_function (/usr/local/lib/python3.8/site-packages/flask_cors/extension.py:165)at full_dispatch_request (/usr/local/lib/python3.8/site-packages/flask/app.py:1952)at wsgi_app (/usr/local/lib/python3.8/site-packages/flask/app.py:2447)我假设这将是版本不匹配,但由于我的 docker 文件正在下载最新的稳定版本85.0.4183.83,即使在将其与chromedriver-binary==85.0.4183.83.0 错误不断发生之后,我也尝试了最新版本的 chromdriver-binary,但85.0.4183.87.0结果是相同。Docker 文件:# Use the official lightweight Python image.# https://hub.docker.com/_/pythonFROM python:3.8-slim# Install manually all the missing librariesRUN apt-get updateRUN apt-get install -y gconf-service wget libasound2 libgbm1 libappindicator3-1 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libxss1 fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils安装过程中没有问题,只有运行过程中出现问题。任何帮助深表感谢。
1 回答
拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
您是否以 root 身份运行驱动程序?如果是这样,请尝试使用该--no-sandbox
选项作为驱动程序的第一个参数。尽管由于存在漏洞,我建议不要以 root 身份运行它。
我从您的评论中看到,这解决了问题,但如果安全性对您的情况确实很重要,我建议您创建一个非 root 用户来运行您的服务。
添加回答
举报
0/150
提交
取消