breuerfelix / chromedriver-py

chromedriver self updated binaries for all platforms
https://pypi.org/project/chromedriver-py/
Apache License 2.0
50 stars 16 forks source link

chromedriver_linux64 unexpectedly exited. Status code was: 127 #10

Closed mohnish7 closed 3 years ago

mohnish7 commented 3 years ago

Trying to run chromedriver in Google Cloud Run. Here is what the docker file looks like:

FROM python:3.7

ADD main.py /

RUN apt-get update
RUN apt-get install wget

# Install Chrome
#RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
#RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install

COPY . /
RUN pip install --upgrade google-api-python-client
RUN pip install -r requirements.txt

EXPOSE XXXXX

CMD [ "python", "./main.py" ]

Any idea how to fix this error? In my requirements file I have chromedriver_py== 92.0.4515.43 mentioned. Any other dependencies that I need to install?

The issue seems to be originating from here:

browser = Chrome(executable_path=binary_path, options=opts)

Here's the options:

opts = Options()
    opts.add_argument("--no-sandbox")
    opts.add_argument("--headless")
    opts.add_argument('--disable-dev-shm-usage')
    opts.add_argument("--window-size=1920x1080")
    opts.add_argument(
        "--user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.43 Safari/537.36'")
    opts.add_argument("--disable-gpu")
    opts.add_argument("--disable-extensions")
    opts.add_argument("--start-maximized")
    browser = Chrome(executable_path=binary_path, options=opts)
breuerfelix commented 3 years ago

well you commented out the chrome installation, and the chromedriver needs chrome to work, so maybe this could be the issue.

another way you can debug this: in the CMD run the chromedriver directly (it should be located somewhere in the pypy packages, you need to search it a little) and then see what the output is, what is the correct error message? if this is working, then add all the flags from your python code to the CMD and see if they work as expected or which error message you get.
because you run the driver directly, you get way more info than from running it through python :)

mohnish7 commented 3 years ago

I ended up using chromedriver directly