Colab не может найти путь хромедрайвера - PullRequest
0 голосов
/ 14 марта 2020

Я пытаюсь создать наборы данных в Google Colab, используя библиотеку google_images_download. Несмотря на установку драйвера chrome, он не может его найти.

Вот мои кодовые ячейки:

%reload_ext autoreload
%autoreload 2
%matplotlib inline

!pip install google_images_download

!wget https://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip  && unzip chromedriver_linux64

import os
#Mount the drive from Google to save the dataset
from google.colab import drive # this will be our driver
drive.mount('/gdrive')
root = '/gdrive/My Drive/'     # if you want to operate on your Google Drive

colab_path = '/gdrive/../content/'

chromedriver_path = '/gdrive/../content/chromedriver'

from google_images_download import google_images_download   #importing the library

keyws   = "jaguar"
limit   = 1000
chromedriver = chromedriver_path
offset  = None  # how many links to skip
color_type  = None# color type you want to apply to the images.[full-color, black-and-white, transparent]
size    = None  #relative size of the image to be downloaded. [large, medium, icon, >400*300, >640*480, >800*600, >1024*768, >2MP, >4MP, >6MP, >8MP, >10MP, >12MP, >15MP, >20MP, >40MP, >70MP]
usage_rights    = 'labeled-for-reuse' #Very important! Check the doc

arguments = {
        "keywords" : keyws,
        "limit" :limit,
        "chromedriver":chromedriver,
        "offset" : offset,
        "color_type" : color_type,
        "size" : size,
        "usage_rights" : usage_rights
        }   #creating list of arguments
response  = google_images_download.googleimagesdownload()   #class instantiation
response.download(arguments)  

И это ошибка:

Item no.: 1 --> Item name = jaguar
Evaluating...
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: Message: Service /gdrive/../content/chromedriver unexpectedly exited. Status code was: -6
)
An exception has occurred, use %tb to see the full traceback.

SystemExit
/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py:2890: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

Это структура файла (извините за прозрачность. Мой скриншот по какой-то причине):

enter image description here

1 Ответ

1 голос
/ 15 марта 2020

Вместо wget ... вы можете установить chromedriver с

!apt install chromium-chromedriver

, а затем указать его путь в аргументах.

"chromedriver": "/usr/bin/chromedriver",
...