---
slug: "ubuntu-chromedriver"
title: "Notes on Installing chromedriver"
description: "Ubuntu 16.04Reference Running Google Chrome in headless mode on EC2 Ubuntu and taking screenshots - Qiitapython 2.7 - Unknown error: Chrome failed to start: exited abnormally - Stack Overflow"
url: "https://www.ytyng.com/en/blog/ubuntu-chromedriver"
publish_date: "2018-08-16T06:07:15Z"
created: "2018-08-16T06:07:15Z"
updated: "2026-02-27T07:02:35.609Z"
categories: []
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/18a00298b16241e2883fb70d5fe41fc6.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Notes on Installing chromedriver

<p>Ubuntu 16.04<br /><br />Reference <a href="https://qiita.com/shinsaka/items/37436e256c813d277d6d" target="_blank">Running Google Chrome in headless mode on EC2 Ubuntu and taking screenshots - Qiita</a><br /><a href="https://stackoverflow.com/questions/22424737/unknown-error-chrome-failed-to-start-exited-abnormally" target="_blank">python 2.7 - Unknown error: Chrome failed to start: exited abnormally - Stack Overflow</a><br /><br /></p>
<h2>Chrome</h2>
<pre>curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb<br />sudo dpkg -i google-chrome-stable_current_amd64.deb</pre>
<pre>sudo apt update<br />sudo apt -f install -y</pre>
<p>Test</p>
<pre>cd /tmp<br />google-chrome --headless --disable-gpu --screenshot <a href="https://www.example.com/">https://www.example.com/</a><br />imgcat screenshot.png  # imgcat will be explained later</pre>
<p></p>
<h2>chromedriver</h2>
<pre>curl <a href="https://chromedriver.storage.googleapis.com/LATEST_RELEASE">https://chromedriver.storage.googleapis.com/LATEST_RELEASE</a><br /><br />curl -O <a href="https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip"></a><a>https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip</a><br /><br />unzip <a href="https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip">chromedriver_linux64.zip<br /><br /></a>sudo mv chromedriver /usr/local/bin/</pre>
<p>Test</p>
<pre>chromedriver --verbose &amp;<br />curl -d '{ "desiredCapabilities": {"browserName": "chrome", "chromeOptions": {"args": [ "--headless" ]} }}' http://127.0.0.1:9515/session</pre>
<p>A sessionId will be returned<br />By the way, if you don't add --headless</p>
<pre>xvfb-run chromedriver --verbose &amp;</pre>
<p>you will need to do this</p>
<p><br />Open a page</p>
<pre>curl -d '{"url":"https://www.example.com"}' <a href="http://127.0.0.1:9515/session/&lt;session-id&gt;/url">http://127.0.0.1:9515/session/&lt;session-id&gt;/url</a></pre>
<p><br />Screenshot</p>
<pre>curl http://127.0.0.1:9515/session/&lt;session-id&gt;/screenshot | python3 -c "import sys, json; print(json.load(sys.stdin)['value'])"|base64 -d |imgcat</pre>
<p>※ Execute the screenshot command ➝ The result will be returned as JSON containing Base64 ➝ Parse with Python ➝ Decode to binary ➝ Display on iterm2 with imgcat</p>
<p></p>
<p>If it doesn't work, try --no-sandbox and --disable-dev-shm-usage</p>
<p>Note: Disable web security with --ignore-certificate-errors and --disable-web-security<br /><br /><br />Reference: https://www.pawangaria.com/post/automation/browser-automation-from-command-line/</p>
<h2>Python Library</h2>
<p>pyvirtualdisplay is required</p>
<pre>sudo apt install xvfb</pre>
<pre>pip install selenium chromedriver pyvirtualdisplay</pre>
<h2><br />Test Code</h2>
<pre style="background-color: #ffffff; color: #000000; font-family: 'Menlo'; font-size: 9.0pt;"><span style="color: #000080; font-weight: bold;">from </span>pyvirtualdisplay <span style="color: #000080; font-weight: bold;">import </span>Display<br />display = Display(<span style="color: #660099;">visible</span>=<span style="color: #0000ff;">0</span>, <span style="color: #660099;">size</span>=(<span style="color: #0000ff;">1280</span>, <span style="color: #0000ff;">800</span>))<br />display.start()<br /><br /><span style="color: #000080; font-weight: bold;">from </span>selenium.webdriver <span style="color: #000080; font-weight: bold;">import </span>Chrome, ChromeOptions<br /><br />options = ChromeOptions()<br />options.add_argument(<span style="color: #008080; font-weight: bold;">'--headless'</span>)<br />options.add_argument(<span style="color: #008080; font-weight: bold;">'--disable-gpu'</span>)<br />driver = Chrome(<span style="color: #660099;">options</span>=options)<br /><br />driver.get('https://example.com')<br />driver.get_screenshot_as_file('/tmp/screenshot.png')</pre>
<p></p>
<h2>Extra: Viewing Images on the Server</h2>
<p>If you are using iTerm</p>
<p><a href="https://gist.github.com/wesbos/eac5f93478002312db1f">https://gist.github.com/wesbos/eac5f93478002312db1f</a> This script</p>
<pre>sudo curl -o /usr/local/bin/imgcat -O https://raw.githubusercontent.com/gnachman/iTerm2/master/tests/imgcat &amp;&amp; sudo chmod +x /usr/local/bin/imgcat</pre>
<p>Install imgcat on the server,</p>
<pre>imgcat /tmp/screenshot.png</pre>
<p>and the image will be displayed in the terminal.</p>
<p></p>
<h2>Note for Mac: Use binaries downloaded from the site</h2>
<p>If you are using chromedriver installed via brew on a Mac, when you use the get method</p>
<pre>data:;</pre>
<p>the URL opens and</p>
<pre>&nbsp;&nbsp;&nbsp; raise RemoteDisconnected("Remote end closed connection without"<br />http.client.RemoteDisconnected: Remote end closed connection without response</pre>
<p>it may stop with this error.</p>
<pre>brew uninstall --force chromedriver</pre>
<p>Uninstall chromedriver with the above command,</p>
<p><a href="http://chromedriver.chromium.org/downloads">http://chromedriver.chromium.org/downloads</a> download the latest Mac binary from here, scan it for viruses, and then place it in <code>/usr/local/bin/</code> for use.</p>
<p></p>
<h2>Troubleshooting</h2>
<p>On Ubuntu</p>
<pre>selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally<br /> (unknown error: DevToolsActivePort file doesn't exist)<br /> (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)<br /> (Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 4.15.0-1023-aws x86_64)</pre>
<p>appears</p>
<p><a href="https://stackoverflow.com/questions/50790733/unknown-error-devtoolsactiveport-file-doesnt-exist-error-while-executing-selen">https://stackoverflow.com/questions/50790733/unknown-error-devtoolsactiveport-file-doesnt-exist-error-while-executing-selen</a> Refer to this</p>
<pre>System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");<br />ChromeOptions options = new ChromeOptions();<br />options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems<br />options.addArguments("start-maximized"); // open Browser in maximized mode<br />options.addArguments("disable-infobars"); // disabling infobars<br />options.addArguments("--disable-extensions"); // disabling extensions<br />options.addArguments("--disable-gpu"); // applicable to windows os only<br />options.addArguments("--no-sandbox"); // Bypass OS security model<br />WebDriver driver = new ChromeDriver(options);<br />driver.get("https://google.com");</pre>
<p>Try adding these options. Note that this code is not in Python.</p>
<p>For me, adding <code>disable-infobars</code> stopped the error.</p>
<p></p>
