我正在尝试使用google_images_download
库在Google Colab上创建数据集。尽管安装了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)
这是文件结构(抱歉,透明度。由于某些原因,我的screenfetch会这样做):
答案 0 :(得分:1)
您可以使用以下方式安装chromedriver,而不是wget ...
:
!apt install chromium-chromedriver
然后在参数中设置其路径。
"chromedriver": "/usr/bin/chromedriver",