gpt4 book ai didi

python - 使用 Chromedriver 制作程序,出现错误 : "Could not get version for Chrome with this command"

转载 作者:行者123 更新时间:2023-12-03 14:43:09 25 4
gpt4 key购买 nike

这是我的代码。我这样做是因为当我尝试放置 chromedriver.exe 的路径时,我要么得到“WebDriverException:消息:'chromedriver.exe'可执行文件可能有错误的权限”或“WebDriverException:消息:'chromedriver'可执行文件需要在 PATH 中”,我不知道如何修复它。

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager


browser = webdriver.Chrome(ChromeDriverManager().install())

运行此代码会出现以下错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-43-614c8d8b619c> in <module>
5
6
----> 7 browser = webdriver.Chrome(ChromeDriverManager().install())
8

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/chrome.py in install(self, path)
17 def install(self, path=None):
18 # type: () -> str
---> 19 bin_file = self._file_manager.download_driver(self.driver, path)
20 os.chmod(bin_file.path, 0o755)
21 return bin_file.path

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/cache.py in download_driver(self, driver, path, subpath)
70 if path is not None:
71 path = os.path.abspath(path)
---> 72 cached_binary = self.get_cached_binary(driver, path, subpath)
73 if cached_binary:
74 return cached_binary

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/cache.py in get_cached_binary(self, driver, path, subpath)
36
37 name = driver.name
---> 38 version = driver.get_version()
39 os_type = driver.os_type
40 console("")

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/driver.py in get_version(self)
32 # type: () -> str
33 if self._version == "latest":
---> 34 return self.get_latest_release_version()
35 return self._version
36

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/driver.py in get_latest_release_version(self)
48 # type: () -> str
49 resp = requests.get(
---> 50 self.config.driver_latest_release_url + '_' + chrome_version()
51 ) # returns chromedriver version for current browser version
52 validate_response(self, resp)

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/utils.py in chrome_version()
60 if not version:
61 raise ValueError(
---> 62 'Could not get version for Chrome with this command: {}'.format(cmd)
63 )
64 return version.group(0)

ValueError: Could not get version for Chrome with this command: google-chrome --version

老实说,我完全不知道我能做些什么来解决这个问题。

最佳答案

这是 webdriver_manager 中的一个错误 link .

为避免此问题,您可以使用 google-chrome-stable 浏览器而不是chromium-browser。

关于python - 使用 Chromedriver 制作程序,出现错误 : "Could not get version for Chrome with this command",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57175675/

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