我正在使用python和selenium,并从这个网站下载了用于我的windows计算机的chromedriver: http://chromedriver.storage.googleapis.com/index.html?path=2.15/

下载压缩文件后,我将压缩文件解压缩到我的下载文件夹中。然后我把可执行二进制文件(C:\Users\michael\Downloads\chromedriver_win32)的路径放到环境变量“path”中。

然而,当我运行以下代码:

  from selenium import webdriver

  driver = webdriver.Chrome()

... 我一直得到以下错误消息:

WebDriverException: Message: 'chromedriver' executable needs to be available in the path. Please look at     http://docs.seleniumhq.org/download/#thirdPartyDrivers and read up at http://code.google.com/p/selenium/wiki/ChromeDriver

但是-如上所述-可执行文件在路径中(!)…这是怎么回事?


当前回答

我在Webdriver 3.8.0 (Chrome 73.0.3683.103和ChromeDriver 73.0.3683.68)上遇到了这个问题。我这么做之后,问题就消失了

pip install -U selenium

将Webdriver升级到3.14.1。

其他回答

简单的解决方案是下载chrome驱动程序并移动 将可执行文件转移到运行python文件的文件夹。

根据指令,当实例化webdriver时,你需要包含到ChromeDriver的路径。如铬。

driver = webdriver.Chrome('/path/to/chromedriver')

在最近的版本中,创建chromedriver的首选方式是使用服务。

手动设置路径,如下所示:

chromedriver_path = "path to your chromedriver executable>"

service = Service(chromedriver_path)
driver = webdriver.Chrome(service=service)

在Ubuntu上:

sudo apt install chromium-chromedriver

在Debian上:

sudo apt install chromium-driver

在macOS上安装Homebrew,然后执行

brew install --cask chromedriver

适用于mac osx用户

    brew tap homebrew/cask
    brew cask install chromedriver