Python Selenium chromedriver OSError:[Errno 8] Exec格式错误

时间:2016-03-21 20:33:37

标签: python macos selenium

我试图在我的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")

具有相同的结果。任何人都知道可能是什么问题?我非常感谢你的帮助!

1 个答案:

答案 0 :(得分:2)

我最终解决了这个问题,卸载了chromedriver的所有实例(我在不同的位置有多个)然后再用homebrew安装它:brew install chromedriver