3

Web scraping with selenium works fine on my mac local machine but when I push to live Ubuntu server, I get the following error

Could not get version for Chrome with this command: google-chrome --version || google-chrome-stable --version

when I try to run

from webdriver_manager.chrome import ChromeDriverManager

chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)

The code is deployed on AWS ec2 instance

Zohaib Shamshad
  • 141
  • 1
  • 12
  • Possibly helpful: https://github.com/SergeyPirogov/webdriver_manager/issues/73 – Mate Mrše Sep 07 '21 at 07:46
  • 1
    Hi, I am supporting webdriver_manager on python. Q: Is google chrome installed on ubuntu or chromium browser? – gore Oct 16 '21 at 07:06
  • @gore installing chromium-chromedriver on ubuntu server worked for me, thank you for your help – Zohaib Shamshad Oct 19 '21 at 08:15
  • @Zohaib. I am glad to hear your problem has been solved. But to be truth: installing chromium-chromedriver from ubuntu's repository is not the solution for webdriver-manager's issue have been described in the topic. You solved it by installing chromium-chromedriver. Then i suggest that you have Chromium browser, not the GoogleChrome. I have added the answer for the question from topic. For the people who will come here with same problem with webdriver-manager. – gore Oct 19 '21 at 09:47
  • Yes, I have chromium browser my bad, I'll try your solution as well and get back – Zohaib Shamshad Oct 20 '21 at 15:45

4 Answers4

3

Possible: you don't have GoogleChrome or your OS doesn't know about it. I suggest that you use Chromium browser.

The solution if you want to download Chromium webdriver by webdriver-manager:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType

webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()
gore
  • 551
  • 2
  • 20
1

As stated by @gore in the comments installing chromium-chromedriver on ubuntu server worked for me

On Ubuntu 20.04

pip install selenium
sudo apt-get update
sudo apt install chromium-chromedriver
Zohaib Shamshad
  • 141
  • 1
  • 12
0

If you are using Chromium, try installing Google Chrome instead of using chromium. As far as I know selenium is designed for Chrome. There is another related topic here: Making program using Chromedriver, getting error: "Could not get version for Chrome with this command"

-3

try it like this

options = webdriver.ChromeOptions()

here's another hint for you http://chromedriver.chromium.org/capabilities

Vadim
  • 1
  • 1