我正在尝试在python(2.7)脚本中使用Selenium建立chrome会话,如下所示:
from selenium import webdriver driver=webdriver.Chrome()
但是我收到以下错误:
Traceback (most recent call last): File "soup_test.py", line 30, in <module> driver=webdriver.Chrome() File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 61, in __init__ self.service.start() File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 62, in start stdout=self.log_file, stderr=self.log_file) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 8] Exec format error
搜索其他问题时,一个常见的问题似乎是chromedriver不在路径上,但我检查了,并在了。我什至尝试明确指定路径:
driver=webdriver.Chrome("/path/to/chromedriver")
具有相同的结果。有人知道可能是什么问题吗?我非常感谢您的帮助!
最终,我通过卸载chromedriver的所有实例(我在不同位置有多个实例)并使用自制软件再次安装来解决了该问题: brew install chromedriver
brew install chromedriver