2017-07-20 81 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