提问人:Leah 提问时间:7/4/2023 最后编辑:Leah 更新时间:7/4/2023 访问量:201
尝试使用 Selenium webdriver 时出现 Chronium 和 snap 的问题 (v 4.10.0)
Issue with Chronium and snap when trying to use Selenium webdriver (v 4.10.0)
问:
我正在尝试使用 Selenium 抓取网站,但我在 Chromium 或通往 chromedriver 的路径方面遇到了一些问题。我是 Selenium 的初学者,但似乎找不到解决方案。
我正在本地 pyenv 中使用 Ubuntu 开发 WSL。 因此,我已将 Linux 和 Windows chromedriver 都移至
driver_path_windows = "/home/leah/.pyenv/versions/3.10.6/envs/vinted-api/bin/chromedriver.exe"
driver_path_linux = "/home/leah/.pyenv/versions/3.10.6/envs/vinted-api/bin/chromedriver"
并且都尝试过
service = Service(driver_path_windows)
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
和
service = Service(driver_path_linux)
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
这些都不起作用,我收到此错误消息 “message”: “消息:未知错误:Chrome 无法启动:异常退出。\n(未知错误:DevToolsActivePort 文件不存在)\n (从 chrome 位置 /usr/bin/chromium-browser 启动的进程不再运行,因此 ChromeDriver 假定 Chrome 已崩溃。
我还尝试在我的桌面中使用 .exe 的路径或仅在标准 WSL 目录中使用路径,但遇到了相同的错误,这让我认为 chromium 存在错误。
当我运行时,我收到以下错误:snap install chromium
✗ chromium-browser --version
Command '/usr/bin/chromium-browser' requires the chromium snap to be installed.
Please install it with:
snap install chromium
✗ snap install chromium
error: cannot communicate with server: Post http://localhost/v2/snaps/chromium: dial unix /run/snapd.socket: connect: no such file or directory
这是snap version
snap 2.54.3+20.04.1ubuntu0.2
snapd unavailable
series -
但是我没有任何错误输入日志
journalctl -u snapd
No journal files were found.
-- No entries --
我能跑sudo apt install chromium-browser
Reading package lists... Done
Building dependency tree
Reading state information... Done
chromium-browser is already the newest version (1:85.0.4183.83-0ubuntu0.20.04.3).
0 upgraded, 0 newly installed, 0 to remove and 245 not upgraded.
但不是sudo snap install chromium
error: cannot communicate with server: Post http://localhost/v2/snaps/chromium: dial unix /run/snapd.socket: connect: no such file or directory
我还尝试下载Chrome的官方Ubuntu版本,基于此解决方案(选项1),无法在WSL上使用snap安装chromium
但我不确定如何让 Chrome 从 WSL 运行
答: 暂无答案
评论