WebDriver异常消息:'chromedriver'可执行文件需要位于PATH中(Mac M1上的错误)



我正在尝试web刮痧与硒,因此以下代码。但是,我遇到chromedriver路径错误,我无法在mac M1上找出。我已经尝试了几种方法来解决这个问题。

提示吗?

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
chromeOptions = Options()
chromeOptions.headless = False
s = Service("usr/local/bin/chromedriver")
driver = webdriver.Chrome(service= s, options = chromeOptions )

我得到以下错误:

---------------------------------------------------------------------------
SeleniumManagerException                  Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py in start(self)
95                 try:
---> 96                     path = SeleniumManager().driver_location(browser)
97                 except WebDriverException as new_err:
7 frames
SeleniumManagerException: Message: Selenium manager failed for: /usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome. /usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/linux/selenium-manager: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.29' not found (required by /usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/linux/selenium-manager)
/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/linux/selenium-manager: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/linux/selenium-manager)

During handling of the above exception, another exception occurred:
WebDriverException                        Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py in _start_process(self, path)
210         except OSError as err:
211             if err.errno == errno.ENOENT:
--> 212                 raise WebDriverException(
213                     f"'{os.path.basename(self.path)}' executable needs to be in PATH. {self.start_error_message}"
214                 )
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

你还需要在路径中提供webdriver的文件名,所以在你的情况下:

usr/local/bin/chromedriver

应该像:

usr/local/bin/chromedriver/chromedriver 

如果文件夹名称与webdriver文件名匹配。至少根据错误,似乎chromedriver是一个文件夹,你已经放置了真正的webdriver文件。

最新更新