我正在尝试在我的 python (2.7) 脚本中设置与 Selenium 的 chrome 会话,如下所示:
from selenium import webdriver
driver=webdriver.Chrome()
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
通过其他问题搜索,一个常见问题似乎是 chromedriver 不在路径上,但我检查过,它是。我什至尝试明确指定路径:
driver=webdriver.Chrome("/path/to/chromedriver")
Run Code Online (Sandbox Code Playgroud)
得到相同的结果。有人知道可能是什么问题吗?我真的很感激你的帮助!