2017-07-20 107 views
0

我打开脚本的浏览器错误而硒

from selenium import webdriver 
o = webdriver.Firefox() 

和我得到这个问题

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 142, in __init__ 
    self.service.start() 
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 74, in start 
    stdout=self.log_file, stderr=self.log_file) 
    File "/usr/lib/python3.5/subprocess.py", line 676, in __init__ 
    restore_signals, start_new_session) 
    File "/usr/lib/python3.5/subprocess.py", line 1283, in _execute_child 
    raise child_exception_type(errno_num, err_msg) 
OSError: [Errno 8] Exec format error 

我搜索它,我发现这个 OSError: [Errno 8] Exec format error selenium

我得到chromedriver并把它在'/ usr/local/bin /' 就像应该的, 它没有帮助
,也做了同样的事情geckodriver Trouble setting up selenium with python3(linux)

什么工作,同样的错误

和我尝试这个镜头

#!usr/bin/python 
#!/usr/bin/env bash 
from selenium import webdriver 
web = webdriver.Firefox(executable_path="/usr/local/bin/chromedriver") 

它给我的错误:

Traceback (most recent call last): 
    File "/root/Desktop/test.py", line 5, in <module> 
    web = webdriver.Firefox(executable_path="/usr/local/bin/chromedriver") 
    File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 142, in __init__ 
    self.service.start() 
    File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 96, in start 
    self.assert_process_still_running() 
    File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running 
    % (self.path, return_code) 
selenium.common.exceptions.WebDriverException: Message: Service /usr/local/bin/chromedriver unexpectedly exited. Status code was: 1 

注意: 操作系统是kali linux SMP Debian 4.9.18-1kali1版本, firefox和selenium是最新的

+0

你可以从命令行运行geckodriver/chromedriver吗?难道是你试图在Linux上运行一个Windows可执行文件,或者在一些不支持它的Linux上的ELF可执行文件,或者类似的东西? –

+0

chromedriver通过命令行工作 – Fathy

回答

0

驱动程序应该更新一个&你试过webdriver.Firefox(driver_path)吗?

+0

我编辑的问题,因为你的解决方案也给我一个错误 – Fathy

+0

看起来像你为Firefox模块添加铬驱动程序路径。为Firefox添加geckodriver。欲了解更多信息,请访问:https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path – jaibalaji

+0

感谢他的工作 版本geckodriver-v0.18.0- linux32.tar.gz 和提取geckdriver的路径是'\ usr \ local \ bin' – Fathy

0

卸载webdriver依赖项的实例并安装正确的与您的操作系统和浏览器版本相对应的一个。同时,当您给chrome路径时,它应该以chrome.exe而不是chrome结尾。

+0

亲爱的linux没有像chrome.exe 这样的事情,我做到了,清楚地读出了问题 – Fathy