Target: Auto execute python selenium script at startup. My current solution worked for like half a year but after updating my pi 3 days ago, python crashes with this exception: selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist.
This is my init code:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-dev-shm-usage')
browser = webdriver.Chrome(chrome_options=chrome_options, service_args=["--verbose", "--log-path=/home/pi/chromedriver.log"])
browser.implicitly_wait(10)
browser.set_window_size(800, 600)
browser.get(...)
And the chromedriver returns:
[1571045268,786][INFO]: Launching chrome: /usr/bin/chromium-browser --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --headless --ignore-certificate-errors --load-extension=/tmp/.org.chromium.Chromium.ka9jxU/internal --log-level=0 --metrics-recording-only --no-first-run --no-sandbox --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.13RyA2 data:,
: getrandom indicates that the entropy pool has not been initialized. Rather than continue with poor entropy, this process will block until entropy is available.
[1571045328,829][INFO]: Failed to connect to Chrome. Attempting to kill it.
[1571045328,842][INFO]: [4c8ff7afd4ca8a1d7e7d0313509df6dc] RESPONSE InitSession ERROR unknown error: DevToolsActivePort file doesn't exist
[1571045328,842][DEBUG]: Log type 'driver' lost 0 entries on destruction
[1571045328,842][DEBUG]: Log type 'browser' lost 0 entries on destruction
[0100/000000.682302:ERROR:zygote_linux.cc(660)] write: Datenübergabe unterbrochen (broken pipe) (32)
I'm using the autostart file ~/.config/lxsession/LXDE-pi/autostart and this command: @/home/pi/script/main.py > /home/pi/script.log 2>&1 &
by the way main.py is flaged as an executable and uses python3.
I have no problem what so ever if I manually start the script via ssh. So I assume that it is caused by missing environment variables or something like that during the start-up / auto-start process causing chromium to crash. As you can see I already tried the answer of this stack overflow question.
My current chromium version is Chromium 72.0.3626.121 Built on Raspbian , running on Raspbian 9.11
and
the chromedriver version is ChromeDriver 72.0.3626.121