4

I am trying to automate some stuff I do day-to-day online and get some experience in webscraping. I saw some stuff about Selenium and Python being good for beginners and thought I would give it a try. I ended up getting a simple script to work on my home computer but it doesn't find the Chrome binary at the path I am giving and I do not know what to do.

I used this to set my PATH environment variable to the directory that holds my chromedriver https://youtu.be/dz59GsdvUF8

I downloaded ChromeDriver 74.0.3729.6 (latest stable release) from https://sites.google.com/a/chromium.org/chromedriver/

I am using python3, visual studio code, and Ubuntu if any of that matters.

import time 
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

#Stack overflow said to try this but could not make it work
#opts = webdriver.ChromeOptions()
#opts.binary_location = "C:\webdrivers\chromedriver.exe"
#browser = webdriver.Chrome(chrome_options=opts)

#this is where my chrome is
#C:\Users\tucker.steven2\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Virtual Programs\Google Chrome\Chrome v62

#I have a chromedriver in the same directory as my python code
browser = webdriver.Chrome('chromedriver.exe')
browser.get(https://www.something.com/) #just a generic site
browser.quit()

My expected result is to open a chrome window to Hulu's website, the error I get is:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.16299 x86_64)

ouflak
  • 2,458
  • 10
  • 44
  • 49
stucker
  • 43
  • 1
  • 1
  • 3
  • Does this answer your question? [WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome](https://stackoverflow.com/questions/50138615/webdriverexception-unknown-error-cannot-find-chrome-binary-error-with-selenium) – Gino Mempin Mar 20 '21 at 02:36

1 Answers1

0

If you are on Ubuntu, which is a distribution of Linux, then your path is all wrong. The YouTube video was for Windows. The file structure is completely different on Linux. Please update with your current operating system where you are trying to run this. Also you don't need to write a script - just to open hulu. You can just make a shortcut and put it on your desktop. If you are trying to do something more complicated that takes a long time to do, that would be a better use case for making a selenium script. I get that you are trying to learn this, which is commendable. If you are really on Ubuntu as your operating system, then you would have a /usr/bin folder where your programs are. If you are running Windows, it would be C:\Users\"Your User Name Goes Here"\Documents or where ever you were going.

Programs would be in C:\Program Files\ or C:\Program Files(x86). I would recommend watching some YouTube videos about the path on your operating system.

The answer depends on your operating system and where you have saved your programs.

NKSM
  • 5,422
  • 4
  • 25
  • 38