3

I am trying to run the following code to pull in some images:

from google_images_download import google_images_download   #importing the library

response = google_images_download.googleimagesdownload()   #class instantiation

arguments = {"keywords":"foxes, shiba inu outside","limit":2000,"print_urls":True}   #creating list of arguments
paths = response.download(arguments)   #passing the arguments to the function
print(paths)   #printing absolute paths of the downloaded images

Because I am trying to do over 100 images I am getting a message saying

Looks like we cannot locate the path the 'chromedriver' (use the '--chromedriver' argument to specify the path to the executable.) or google chrome browser is not installed on your machine (exception: expected str, bytes or os.PathLike object, not NoneType)

I am unsure how to integrate the chromedriver piece into my code and set the path. I searched around but I cannot find a clear answer. I tried adding the line

browser = webdriver.Chrome(executable_path=r"/Users/jerelnovick/Desktop/Projects/Image_Recognition/chromedriver.exe")

as I read in one post but that gave me a message saying

WebDriverException: Message: 'Image_Recognitionchromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

I am using a Mac.

halfer
  • 19,824
  • 17
  • 99
  • 186
Jerel
  • 73
  • 1
  • 2
  • 6

1 Answers1

4

There are some additional steps to take to get more than 100 images. From the docs:

If you would want to download more than 100 images per keyword, then you will need to install ‘selenium’ library along with ‘chromedriver’ extension.

And then your arguments will need to be updated as:

arguments = {"keywords":"foxes, shiba inu outside",
             "limit":2000,
             "print_urls":True,
             "chromedriver":"/Users/jerelnovick/Desktop/Projects/Image_Recognition/chromedriver"}

Also make sure the chromedriver you download is the proper one for mac.

MyNameIsCaleb
  • 4,409
  • 1
  • 13
  • 31
  • If that doesn't work, then hardcode line 177 of google_images_download.py where it says browser = webdriver.Chrome(chromedriver, chromeoptions=options) and set the chromedriver variable to the absolute path such as "C:/Users\YourUserName\Desktop\google-images-download-master\google_images_download\chromedriver.exe" – Philip Oct 17 '19 at 12:13
  • MyNameIsCaleb's response is working perfectly. Thank you. – Jerel Oct 17 '19 at 16:41
  • @Jerel glad it is working. Please hit the checkmark next to my answer. :) – MyNameIsCaleb Oct 17 '19 at 16:42