0

I'm trying to scrape images from google images using the google_images_download library by using it from another Python file. I previously used the code below about a month ago and it was fine but today morning it threw exception errors and then finally gave me the error

Unfortunately all 100 could not be downloaded because some images were not downloadable

I checked the documentation and GIT repo and noticed there were changes made 15 days ago, is there something I'm missing or is the library bugged? Also if there are better methods than this, kindly point me in the right direction. My code is below:

from google_images_download import google_images_download
response = google_images_download.googleimagesdownload()

arguments = {"keywords":"potato harvesting","limit":100,"format":"jpg","print_urls":True}
paths = response.download(arguments)
James Z
  • 12,209
  • 10
  • 24
  • 44
Higg_kaz
  • 65
  • 1
  • 3
  • 9
  • There is fork available to solve above error in this issues thread: https://github.com/hardikvasa/google-images-download/issues/331 – Ash Ishh Feb 15 '21 at 16:17
  • @Ash-Ishh.. ive tried re-installing the program with that same fork ( pip install google_images_download) and I still cant get it to run,or is there a way im supposed to install it? – Higg_kaz Feb 15 '21 at 17:47
  • That is the correct way assuming you have cloned the forked repo and it is in directory google_images_download.. try with --upgrade flag in pip install.. if version is same in both it won't upgrade to latest package.. not sure if that is the case but you can try – Ash Ishh Feb 16 '21 at 16:24
  • sorry what do you mean "it is in directory google_images_download.." still havent got it running yet – Higg_kaz Feb 23 '21 at 09:08
  • 1
    I see you got it sorted.. what I meant was if google_images_download is present in your current directory pip will install locally otherwise it will try to fetch it from pypi.. also one more tip to check if correct package is installed is to do pip freeze it will print url and commit of github repo if you installed locally – Ash Ishh Feb 23 '21 at 17:59
  • Thank you so much for the help and the tips, especially the pip freeze tip. Definitely come in handy, thanks again. – Higg_kaz Feb 24 '21 at 06:47

1 Answers1

0

I figured a way to fix the error ,through using the CLI instead of a Jupyter Notebook file. I will list down the steps:

  1. First issue is probably how to uninstall the dependencies. Since I used the python setup.py install, I manually had to uninstall them, luckily I found python setup.py uninstall and the procedure is layed out there on how to manually uninstall (highest voted answer).
  2. I then cloned the repo again in a new folder using !git clone https://github.com/Joeclinton1/google-images-download.git via the CLI and then opened the files by cd google-images-download.
  3. After ,I reinstalled the packages using pip install . NOT python setup.py install.
  4. Use the CLI to download images by following the repo instructions in https://google-images-download.readthedocs.io/en/latest/examples.html.

This worked for me and hopefully will work for you. Note: I cloned the repo in a new folder on the desktop for ease. The downloaded images will be in the same repo folder i.e. google-images-download under the Download file.

Higg_kaz
  • 65
  • 1
  • 3
  • 9