简体   繁体   English

在带有铬的Raspberry Pi上使用硒

[英]Using Selenium on Raspberry Pi with Chromium

So I'm trying to run Selenium on my raspberry pi using Chromium and for some reason I can't get my python file to compile. 因此,我试图使用Chromium在树莓派上运行Selenium,由于某种原因,我无法编译python文件。 I keep getting the following error: 我不断收到以下错误:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver.exe'))
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/service.py", line 75, in start
os.path.basename(self.path), docs_msg)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Here is the python code I'm trying to run: 这是我要运行的python代码:

from selenium import webdriver
import os

driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver'))

driver.get("http://www.google.com")

driver.quit()

Any ideas? 有任何想法吗?

Update 更新资料

After removing the '.exe' at the end of chromedriver, it now produces the following error: 在chromedriver末尾删除“ .exe”后,现在会产生以下错误:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver'))
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/service.py", line 68, in start
self.service_args, env=env, stdout=PIPE, stderr=PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

At the moment Chrome Driver dont support ARM processors architecture anymore. 目前,Chrome驱动程序不再支持ARM处理器架构。

https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=95322 https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=95322

Ubuntu has builds of chromium-chromedriver as .deb files for armhf. Ubuntu为armhf生成了Chrome-chromedriver作为.deb文件。

On launchpad, therefore, you can find chromium-chromedriver armhf builds available for download. 因此,在启动板上 ,您可以找到可下载的chrome-chromedriver armhf版本 Just download the latest version, and since they have no dependencies, you can install by running dpkg -i chromium-chromedriver_58.0.3029.96-0ubuntu0.14.04.1174_armhf.deb . 只需下载最新版本,由于它们没有依赖性,因此可以通过运行dpkg -i chromium-chromedriver_58.0.3029.96-0ubuntu0.14.04.1174_armhf.deb Then chromedriver will be available in /usr/lib/chromium-browser/chromedriver . 然后chromedriver将在/usr/lib/chromium-browser/chromedriver

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

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