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

查看:836
本文介绍了Python Selenium chromedriver OSError:[Errno 8] Exec格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在python(2.7)脚本中使用Selenium建立chrome会话:

I'm trying to set up a chrome session with Selenium in my python (2.7) script like this:

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不在路径上,但我检查了,确实在.我什至尝试明确指定路径:

Searching through other questions a common issue seems to be that chromedriver is not on the path, but I checked and it is. I even tried specifying the path explicitly:

driver=webdriver.Chrome("/path/to/chromedriver")

具有相同的结果.有人知道可能是什么问题吗?非常感谢您的帮助!

with the same result. Anyone know what could be the problem? I'd really appreciate the help!

推荐答案

我最终解决了问题,方法是卸载所有chromedriver实例(我在不同位置有多个实例),然后使用自制软件再次安装它:brew install chromedriver

I eventually solved the problem by uninstalling all instances of chromedriver (I had multiple in different locations) and then installing it again with homebrew: brew install chromedriver

这篇关于Python Selenium chromedriver OSError:[Errno 8] Exec格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆