【发布时间】:2021-09-19 04:45:47
【问题描述】:
我尝试在 Google Colab 上使用 Selenium,然后出现错误。
错误消息是"chromedriver' executable needs to be in PATH."
我用谷歌搜索并找到了解决方案。 解决方法如下:
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('chromedriver',options=options)
当我删除--headless 选项时,出现以下错误。
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
如果没有--headless 选项,是否无法在 Google Colab 上使用 Selenium?
【问题讨论】:
标签: python selenium selenium-webdriver selenium-chromedriver google-colaboratory