简体   繁体   English

[Raspberry Pi3B +]无法在Selenium python3上使用Firefox Webdriver

[英][Raspberry Pi3B+]Can't use Firefox webdriver on Selenium python3

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.google.com/')

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1128, in _execute_prepared_user_code exec(statements, global_vars) 追溯(最近一次调用):文件“ /usr/lib/python3/dist-packages/thonny/backend.py”,行1128,在_execute_prepared_user_code exec(语句,global_vars)中

File "/home/pi/Desktop/test1.py", line 3, in driver = webdriver.Firefox() 在驱动程序= webdriver.Firefox()中,文件“ /home/pi/Desktop/test1.py”,第3行

File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in init self.service.start() 初始化 self.service.start()中的第164行的文件“ /home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py”

File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 76, in start stdin=PIPE) 在开始stdin = PIPE处的文件“ /home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py”,第76行)

File "/usr/lib/python3.5/subprocess.py", line 676, in init restore_signals, start_new_session) 初始化 restore_signals中的文件“ /usr/lib/python3.5/subprocess.py”,行676,start_new_session)

File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child raise child_exception_type(errno_num, err_msg) _execute_child中的文件“ /usr/lib/python3.5/subprocess.py”,行1282引发child_exception_type(errno_num,err_msg)

OSError: [Errno 8] Exec format error OSError:[Errno 8]执行格式错误

During handling of the above exception, another exception occurred: 在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1105, in execute_source return self._prepare_hooks_and_execute(bytecode, None, global_vars) 追溯(最近一次调用):文件“ /usr/lib/python3/dist-packages/thonny/backend.py”,行1105,在execute_source中返回self._prepare_hooks_and_execute(字节码,无,global_vars)

File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1120, in _prepare_hooks_and_execute return self._execute_prepared_user_code(statements, expression, global_vars) _prepare_hooks_and_execute中的文件“ /usr/lib/python3/dist-packages/thonny/backend.py”,行1120返回self._execute_prepared_user_code(语句,表达式,global_vars)

File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1137, in _execute_prepared_user_code return {"user_exception": self._vm._prepare_user_exception()} _execute_prepared_user_code中的文件“ /usr/lib/python3/dist-packages/thonny/backend.py”,行1137返回{“ user_exception”:self._vm._prepare_user_exception()}

File "/usr/lib/python3/dist-packages/thonny/backend.py", line 993, in _prepare_user_exception "stack": self._export_stack(last_frame), _prepare_user_exception“堆栈”中的文件“ /usr/lib/python3/dist-packages/thonny/backend.py”,行993:self._export_stack(last_frame),

File "/usr/lib/python3/dist-packages/thonny/backend.py", line 896, in _export_stack locals=self.export_variables(system_frame.f_locals), 在_export_stack locals = self.export_variables(system_frame.f_locals)中的文件“ /usr/lib/python3/dist-packages/thonny/backend.py”,行896,

File "/usr/lib/python3/dist-packages/thonny/backend.py", line 850, in export_variables result[name] = self.export_value(variables[name], 100) 在export_variables result [name] = self.export_value(variables [name],100)中的文件“ /usr/lib/python3/dist-packages/thonny/backend.py”,第850行

File "/usr/lib/python3/dist-packages/thonny/backend.py", line 840, in export_value rep = repr(value) 在export_value中的文件“ /usr/lib/python3/dist-packages/thonny/backend.py”,行840 rep = repr(value)

File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 164, in repr type(self), self.session_id) 文件“ /home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py”,第164行, 代表类型(self),self.session_id)

AttributeError: 'WebDriver' object has no attribute 'session_id' AttributeError:“ WebDriver”对象没有属性“ session_id”

  1. Reinstall selenium with pip3 install selenium pip3 install selenium重新pip3 install selenium
  2. Download and unzip geckodriver , move to /usr/local/bin 下载并解压缩geckodriver ,移至/ usr / local / bin
  3. Install firefox with sudo apt-get install firefox-esr 使用sudo apt-get install firefox-esr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM