LoginSignup
8
3

More than 3 years have passed since last update.

chromedriver-binary(Python)をChromeのバージョンに合わせてインストールする@Windows

Last updated at Posted at 2019-09-24

TL;DR

Pythonの「chromedriver-binary」をインストールする際には、インストールされている「Google Chrome」のバージョンと同期を取る必要がある。標準的手順は、こんな感じ?

  1. Google Chromeを起動する
  2. URL欄に[chrome://settings/help]を入力し、表示されたバージョンを控える
  3. chromedriver-binaryのページで、適合しそうなバージョンを探す
  4. pip install chromedriver-binary==77.0.3865.40

なんかこう、スマートじゃないので、1行でなんとかしたい!

参考にしました

ChromeとPythonのchromedriver-binaryのバージョンを合わせたい。 - Qiita

動作環境

  • Windows 10
  • PowerShell 6.2.2

PowerShell版

pip install chromedriver-binary<=$(ls "C:\Program Files (x86)\Google\Chrome\Application" | %{$_.name} | findstr "^[0-9].*")

コマンドプロンプト版

for /f "tokens=1" %V in ('dir /B /O-N "C:\Program Files (x86)\Google\Chrome\Application" ^|findstr "^[0-9].*" ') do pip install chromedriver-binary^<^=%V

感想

スマートにしようとしたのに、より泥臭い!!より良い解があれば、ぜひ。。。

8
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3