gpt4 book ai didi

python - 在带有 Chromium 的 Raspberry Pi 上使用 Selenium

转载 作者:行者123 更新时间:2023-12-04 19:03:25 28 4
gpt4 key购买 nike

所以我正在尝试使用 Chromium 在我的树莓派上运行 Selenium,但由于某种原因我无法编译我的 python 文件。我不断收到以下错误:

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

这是我尝试运行的python代码:
from selenium import webdriver
import os

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

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

driver.quit()

有任何想法吗?

更新

删除 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

最佳答案

Ubuntu 将chromium-chromedriver 构建为armhf 的.deb 文件。

因此,在启动板上,您可以找到 chromium-chromedriver armhf builds可供下载。只需下载最新版本,由于它们没有依赖项,您可以通过运行 dpkg -i chromium-chromedriver_58.0.3029.96-0ubuntu0.14.04.1174_armhf.deb 进行安装。 .然后 chromedriver 将在 /usr/lib/chromium-browser/chromedriver 中可用.

关于python - 在带有 Chromium 的 Raspberry Pi 上使用 Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31190164/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com