【问题标题】:Colab can't find chromedriver pathColab 找不到 chromedriver 路径
【发布时间】:2020-06-26 10:30:50
【问题描述】:

我正在尝试使用 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 出于某种原因这样做):

【问题讨论】:

    标签: python google-drive-api dataset google-colaboratory


    【解决方案1】:

    代替wget ...,你可以安装chromedriver

    !apt install chromium-chromedriver
    

    然后在参数中设置它的路径。

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

    【讨论】:

      猜你喜欢
      • 2016-07-24
      • 1970-01-01
      • 2020-03-08
      • 1970-01-01
      • 1970-01-01
      • 2013-12-21
      • 2019-06-04
      • 1970-01-01
      相关资源
      最近更新 更多