我正在尝试在 Raspberry Pi 3 上以 headless 模式运行 Chromium。我从 this repository 获取了 Chromium-chromedriver 。我不断收到同样的错误。当我尝试从终端运行 chromium-chromedriver 时,它说我缺少 libgfx.so,经过一番寻找后,我找不到 Raspberry Pi 的任何地方。我也尝试从终端安装。下面是我的代码以及我尝试过的所有内容以及相应的错误。此时,我们感谢任何和所有的帮助。
我的代码:
from selenium.webdriver import Chrome
from contextlib import closing
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
with closing(Chrome(chrome_options=chrome_options)) as driver:
driver.get(URL)
给出错误:
python3 Chromium\ Launch\ Test.py
Traceback (most recent call last):
File "Chromium Launch Test.py", line 3, in <module>
with closing(Chrome(chrome_options=chrome_options)) as driver:
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /usr/lib/chromium-browser/chromedriver unexpectedly exited. Status code was: 12
尝试从终端运行 chromium-chromedriver:
/usr/lib/chromium-browser/chromedriver: error while loading shared libraries: libgfx.so: cannot open shared object file: No such file or directory
尝试从终端安装 libgfx:
sudo apt install libgfx
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libgfx
根本不知道该去哪里。启动前尝试更新。尝试单独更新存储库中列出的所有依赖库。什么都不起作用。
最佳答案
我一直在解决这个完全相同的问题。在设置了 ubuntu 虚拟机并在那里完成我的开发之后,我知道解决方案有效,我想将其移回我的 pi。我找到了这个驱动程序,它可以工作https://github.com/electron/electron/releases/download/v1.6.0/chromedriver-v2.21-linux-armv7l.zip
关于python - Raspberry Pi 上的 Chromium-Chromedriver 缺少 libgfx 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49071664/