Python 分裂脚本在升级到 Debian Buster 后失败,并出现 chromedriver 异常



我最近从 Stretch 将我的 raspberry 3 升级到 Debian Buster。我有几个使用splinter,Selenium和chromedriver的python脚本。升级后,脚本失败。在尝试进行故障排除时,我创建了一个简单的脚本,该脚本按预期工作:

from selenium import webdriver
from splinter import Browser
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(options=chrome_options)
driver.get('https://python.org')
html = driver.page_source
print(html)
driver.quit()

稍微修改脚本以使用分裂:

from selenium import webdriver
from splinter import Browser
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
with Browser('chrome', headless=True, options=chrome_options) as browser:
browser.visit('https://python.org')
print(browser.html)

给:

Traceback (most recent call last):
File "sel.py", line 8, in <module>
print(browser.html)
File "/usr/local/lib/python3.7/dist-packages/splinter/driver/webdriver/__init__.py", line 201, in html
return self.driver.page_source
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 679, in page_source
return self.execute(Command.GET_PAGE_SOURCE)['value']
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Session info: headless chrome=74.0.3729.157)
(Driver info: chromedriver=74.0.3729.157 (7b16107ab85c5364cdcd0b2dea2539a1f2dc327a-refs/branch-heads/3729@{#998}),platform=Linux 4.19.66-v7+ armv7l)

以下是一些其他信息:

pip3 list |egrep "splinter|selenium"
selenium            3.141.0
splinter            0.11.0
apt-show-versions chromium-browser chromium-chromedriver python3
chromium-browser:armhf/buster 74.0.3729.157-rpt5 uptodate
chromium-chromedriver:armhf/buster 74.0.3729.157-rpt5 uptodate
python3:armhf/buster 3.7.3-1 uptodate
ls -l `which chromedriver`
-rwxr-xr-x 1 root root 10870000 Jul 10 08:27 /usr/bin/chromedriver
chromedriver --version
ChromeDriver 74.0.3729.157 (7b16107ab85c5364cdcd0b2dea2539a1f2dc327a-refs/branch-heads/3729@{#998})

必须发生什么才能让碎片再次工作?

因此,在继续研究之后,我发现解决此问题的最佳方法是降级我已安装的版本。谷歌搜索后,我运行apt-cache madison chromium-chromedriver chromium-browser尝试强制下载,但在 buster 部分没有以前的版本。

所以,我然后重新添加了源代码deb http://archive.raspberrypi.org/debian/ stretch main/etc/apt/sources.listapt-get update

然后我重新运行apt-cache madison chromium-chromedriver chromium-browser给予:

chromium-chromedriver | 74.0.3729.157-rpt5 | http://archive.raspberrypi.org/debian buster/main armhf Packages
chromium-chromedriver | 72.0.3626.121-0+rpt4 | http://archive.raspberrypi.org/debian stretch/main armhf Packages
chromium-browser | 74.0.3729.157-rpt5 | http://archive.raspberrypi.org/debian buster/main armhf Packages
chromium-browser | 72.0.3626.121-0+rpt4 | http://archive.raspberrypi.org/debian stretch/main armhf Packages

在几次尝试获取适当的依赖项后,我运行了apt-get install chromium-chromedriver=72.0.3626.121-0+rpt4 chromium-browser=72.0.3626.121-0+rpt4 chromium-codecs-ffmpeg-extra=72.0.3626.121-0+rpt4 chromium-browser-l10n=72.0.3626.121-0+rpt4

验证我的脚本是否再次运行后,我想标记这些包,以便它们不会更新apt-mark hold chromium-chromedriver chromium-browser chromium-codecs-ffmpeg-extra chromium-browser-l10n

在某些时候,我可能会再次尝试麦迪逊,看看是否有更新的版本并取消保留软件包以查看新版本是否有效 - 但看起来我现在很好。

相关内容

  • 没有找到相关文章

最新更新