我正在使用webdriver硒。我遇到以下错误:
WebDriverException Traceback (most recent call last)
<ipython-input-10-25c7a5245744> in <module>()
1 from selenium import webdriver
----> 2 driver = webdriver.Chrome()
3 driver.get("http://www.google.com")
4 display.stop()
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
71 service_args=service_args,
72 log_path=service_log_path)
---> 73 self.service.start()
74
75 try:
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self)
96 count = 0
97 while True:
---> 98 self.assert_process_still_running()
99 if self.is_connectable():
100 break
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
109 raise WebDriverException(
110 'Service %s unexpectedly exited. Status code was: %s'
--> 111 % (self.path, return_code)
112 )
113
WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: -6
我使用了chromium-browser version (70.0.3538.77-0ubuntu0.18.04.1)
,selenium 3.141.0
和chromedriver version 2.43
。
我从许多来源进行搜索,发现错误是铬版本。因此,我尝试使用!sudo apt-get install -y chromium-browser
尽管如此,它不适用于我的Google colab。
请帮助我解决该问题。非常感谢!
答案 0 :(得分:1)
sudo snap install chromium
对我来说,这就是问题所在。通常,sudo apt install chromium-chromedriver
也会安装该管理单元,但是如果不需要,则必须手动安装该管理单元。
答案 1 :(得分:0)
from selenium import webdriver
driver = webdriver.Chrome('/path/to/chromedriver')
driver.get("http://www.google.com")
display.stop()
您需要从https://chromedriver.storage.googleapis.com/index.html?path=2.43/下载ChromeDriver可执行文件