OSError: [Errno 8] Exec format error selenium

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

Trying to learn how to use selenium, I managed to overcome first error which involved chrome driver not being in the path name but it has thrown up another error.

  from selenium import webdriver     from selenium.webdriver.common.keys import Keys       driver = webdriver.Chrome('/Users/williamneal/Scratch/Titanic/chromedriver')     driver.get("http://www.bbc.com")

The error: Traceback (most recent call last):

  File "", line 5, in      driver = webdriver.Chrome('/Users/williamneal/Scratch/Titanic/chromedriver')    File "/Users/williamneal/anaconda/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__     self.service.start()    File "/Users/williamneal/anaconda/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 64, in start     stdout=self.log_file, stderr=self.log_file)    File "/Users/williamneal/anaconda/lib/python3.5/subprocess.py", line 950, in __init__     restore_signals, start_new_session)    File "/Users/williamneal/anaconda/lib/python3.5/subprocess.py", line 1544, in _execute_child     raise child_exception_type(errno_num, err_msg)  OSError: [Errno 8] Exec format error

There is a potential solution here, which involves installing Chrome Drivers via Home Brew but that option is not available to me.

Any ideas?

回答1:

Looks like this is complaining about the format of chromedriver binary. It might be because of platform and chromedriver format mismatch. For example windows requires chromedriver.exe while there are different formats for linux and mac.

If you don't want to install through package manager, just download chromedriver from https://sites.google.com/a/chromium.org/chromedriver/downloads

Note : Choose file as per your os

Then place it anywhere on the os and pass that path as an argument. You can also set webdriver.chrome.driver environment variable if you don't want to pass the location every time.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!