Python 3.x 从selenium打开浏览器时出错

Python 3.x 从selenium打开浏览器时出错,python-3.x,selenium,webdriver,selenium-chromedriver,Python 3.x,Selenium,Webdriver,Selenium Chromedriver,我的剧本 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

我的剧本

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
这给了我一个错误:

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
回溯(最近一次呼叫最后一次):
文件“/root/Desktop/test.py”,第5行,在
web=webdriver.Firefox(可执行文件路径=“/usr/local/bin/chromedriver”)
文件“/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py”,第142行,在__
self.service.start()
文件“/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py”,第96行,开始
self.assert\u进程\u仍在运行()
文件“/usr/local/lib/python3.5/dist packages/selenium/webdriver/common/service.py”,第109行,断言进程仍在运行
%(self.path,返回\u代码)
selenium.common.exceptions.WebDriverException:消息:Service/usr/local/bin/chromedriver意外退出。状态代码为:1
注: 操作系统是kali-linux SMP Debian 4.9.18-1Cali1版本,
firefox和selenium是最新的

驱动程序应该更新一个&您是否尝试过webdriver.firefox(驱动程序路径)?

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

您能从命令行运行geckodriver/chromedriver吗?可能是您试图在Linux上运行windows可执行文件,或者在不支持它的Linux上运行ELF可执行文件,或者类似的东西吗?chromedriver通过命令行为我工作我编辑这个问题,因为您的解决方案给了我一个错误工具,例如添加Firefox模块的chrome驱动程序路径。为firefox添加geckodriver。欲了解更多信息,请访问:感谢geckodriver-v0.18.0-linux32.tar.gz版本的工作,提取geckdriver的路径是“\usr\local\bin”好消息!!!你能通过点击我答案旁边的勾号来接受答案吗,就在投票向上/向下箭头下方,所以勾号变为绿色?感谢它的linux没有像chrome.exe这样的东西,我做到了,把问题读清楚了
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