[英]Error using selenium with chromedriver on raspberry Pi 3 - Raspbian Jessie
I try to execute this ::我尝试执行这个::
from selenium import webdriver
import time
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
import schedule
from datetime import datetime
driver = webdriver.Chrome('/home/pi/Documents/chromedriver')
driver.get('http://google.com')
time.sleep(5)
Here is the error I get :这是我得到的错误:
Traceback (most recent call last):
File "test2.py", line 12, in <module>
driver = webdriver.Chrome('/home/pi/Documents/chromedriver') # Optional arg$
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
Is there anybody who know how to solve it ?有没有人知道如何解决它? I tried also with firefox and xvfb with no success for the moment.我也尝试过 firefox 和 xvfb,但暂时没有成功。
Here is the path define in '.bashrc' :这是在 '.bashrc' 中定义的路径:
export $PATH=$PATH:/home/pi/Documents/chromedriver
Not sure if this will help you, but I set up my selenium environment on my Ubuntu machines (raspberry pi should be similar enough) using this helper script.不确定这是否会帮助你,但我使用这个帮助脚本在我的 Ubuntu 机器上设置了我的 selenium 环境(树莓派应该足够相似)。 Install setupdriver.sh安装 setupdriver.sh
echo "removing chromium-browser"
sudo apt-get purge chromium-browser
rm ~/.config/chromium/ -rf
echo "removing chrome"
sudo apt-get purge google-chrome-stable
rm ~/.config/google-chrome/ -rf
sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
echo "installing Chrome"
echo "getting libxi6"
sudo apt-get install libxi6 libgconf-2-4
echo "getting chromedriver2.27"
wget -N https://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip
echo "unzipping chromedriver2.27"
unzip chromedriver_linux64.zip
echo "exe chromedriver"
chmod +x chromedriver
echo "removing /usr/local/share/chromedriver"
sudo rm -rf /usr/local/share/chromedriver
echo "removing /usr/local/bin/chromedriver"
sudo rm -rf /usr/local/bin/chromedriver
echo "removing /usr/bin/chromedriver"
sudo rm -rf /usr/bin/chromedriver
echo "moving chromedriver to local/share"
sudo mv -f chromedriver /usr/local/share/chromedriver
echo "linking to bin"
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
echo "linking to local bin"
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
so try copying that code into a shell file.所以尝试将该代码复制到 shell 文件中。 chmod +x
the file, then sh filename.sh
or you can copy type each step directly into terminal. chmod +x
文件,然后sh filename.sh
或者您可以将每个步骤直接复制到终端中。
I had to use this legacy driver:我不得不使用这个遗留驱动程序:
https://github.com/electron/electron/releases/download/v1.6.0/chromedriver-v2.21-linux-armv7l.zip https://github.com/electron/electron/releases/download/v1.6.0/chromedriver-v2.21-linux-armv7l.zip
I referred to this question on reddit Success: How to run Selenium Chrome webdriver on Raspberry pi and through the comments I saw this explanation that turned out to install chromium-chromedriver
properly and solved my issue. 我在reddit 成功案例中提到了这个问题:如何在Raspberry pi上运行Selenium Chrome webdriver ,通过评论,我看到了这一解释,结果证明正确安装了chromium-chromedriver
并解决了我的问题。
by this code sudo apt-get install chromium-driver
@vladoportos. 通过此代码sudo apt-get install chromium-driver
Chrome sudo apt-get install chromium-driver
@vladoportos。
Oh and it might be useful if you check the python version(update). 哦,如果您检查python版本(更新),这可能会很有用。
Based on this post, the command to install chromedriver is the follwing:根据这篇文章, 安装 chromedriver 的命令如下:
sudo apt-get install chromium-chromedriver
and you will have 74.0.3729.157 version of ChromeDriver available in the system.并且您将在系统中使用 74.0.3729.157 版本的 ChromeDriver。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.