splinter icon indicating copy to clipboard operation
splinter copied to clipboard

Error in Docker Container, "unknown error: DevToolsActivePort file doesn't exist"

Open oliverdixon85 opened this issue 3 years ago • 2 comments

I'm trying to run a program in a Docker container using Splinter. Here is my Dockerfile

FROM python:3.7-alpine

COPY requirements.txt . 

RUN apk update && \
    apk add make automake gcc g++ subversion python3-dev && \
    apk add gcc musl-dev python3-dev libffi-dev openssl-dev && \
    apk add chromium chromium-chromedriver && \
    pip install -r /requirements.txt && \
    rm -rf /root/.[acpw]* ipaexg00301*

COPY . /app

After creating the container and running my code in it I get the following error:

Traceback (most recent call last): File "/app/youversion_ingress.py", line 387, in main() File "/app/youversion_ingress.py", line 375, in main books_df, grouped_df = books_chapter_count(exploded, max_chapters) File "/app/youversion_ingress.py", line 224, in books_chapter_count browser = Browser('chrome') File "/usr/local/lib/python3.6/site-packages/splinter/browser.py", line 101, in Browser return get_driver(driver, retry_count=retry_count, *args, **kwargs) File "/usr/local/lib/python3.6/site-packages/splinter/browser.py", line 76, in get_driver raise err File "/usr/local/lib/python3.6/site-packages/splinter/browser.py", line 72, in get_driver return driver(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/splinter/driver/webdriver/chrome.py", line 43, in init self.driver = Chrome(options=options, **kwargs) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init desired_capabilities=desired_capabilities) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Running my script locally on my machine works fine so it must be something within Docker container. Input and comments would be appreciated.

oliverdixon85 avatar Jul 22 '22 13:07 oliverdixon85

I also just tried this Docker script and got another error.

FROM python:3.7-alpine

COPY requirements.txt . 

RUN echo "http://dl-4.alpinelinux.org/alpine/v3.14/main" >> /etc/apk/repositories && \
    echo "http://dl-4.alpinelinux.org/alpine/v3.14/community" >> /etc/apk/repositories

RUN apk update && \
    apk add make automake gcc g++ subversion python3-dev && \
    apk add gcc musl-dev python3-dev libffi-dev openssl-dev && \
    apk add chromium chromium-chromedriver && \
    pip install selenium && \
    pip install -r /requirements.txt && \
    rm -rf /root/.[acpw]* ipaexg00301*

ENV CHROME_BIN=/usr/bin/chromium-browser \
    CHROME_PATH=/usr/lib/chromium/

COPY . /app

New Error Message selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

oliverdixon85 avatar Jul 22 '22 14:07 oliverdixon85

@oliverdixon85 These are chromedriver errors, so your issue isn't splinter related. There's nothing we can do from this side.

However, this is probably a permissions issue or a path issue. If chromedriver isn't in the system PATH, you can try specifying the path using a Service object:

https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/#python-1

https://www.selenium.dev/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.service.html#module-selenium.webdriver.chrome.service

jsfehler avatar Jul 28 '22 17:07 jsfehler