LoginSignup
0
0

More than 1 year has passed since last update.

pipでSeleniumをインストールしてブラウザを自動操作しよう!

Last updated at Posted at 2022-08-02

Seleniumは、ブラウザ自動化を可能にするツール群・ライブラリ群のプロジェクトです。

今回は、PythonでSeleniumを扱う想定で、Pythonのパッケージを管理するためのツールであるpipでSeleniumをインストールしていきます!

5分もあれば終わる作業でした👍

Pythonとpipがインストールされていることが前提になります!

Pythonをインストールする方法はこちら

Seleniumをインストールする方法

こちらのコマンドを実行します!

% pip3 install selenium
% pip3 install selenium
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting selenium
  Downloading selenium-4.1.0-py3-none-any.whl (958 kB)
     |████████████████████████████████| 958 kB 6.1 MB/s

・・・(省略)

Installing collected packages: selenium
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Successfully installed selenium-4.1.0
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the '/opt/homebrew/opt/python@3.9/bin/python3.9 -m pip install --upgrade pip' command.

Successfully installed seleniumと出ていますので、インストール成功です!

ただ、何やらWarningが出ていますね・・・?

WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the '/opt/homebrew/opt/python@3.9/bin/python3.9 -m pip install --upgrade pip' command.

これは、君のpipのバージョンは『21.3.1』だけど、もっとバージョンが新しい『22.0.3』が使えますんで、アップグレードしたらいかが? という警告です。

アドバイス通り、コマンドを実行したいと思います。

% pip3 install --upgrade pip
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: pip in /opt/homebrew/lib/python3.9/site-packages (21.3.1)
Collecting pip
  Downloading pip-22.0.3-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 5.3 MB/s            
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.3.1
    Uninstalling pip-21.3.1:
      Successfully uninstalled pip-21.3.1
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Successfully installed pip-22.0.3

Successfully installed pip-22.0.3と出ましたのでOKですね👍

もしSeleniumのインストールでエラーが出たら?
以下を参照ください!

Seleniumをアンインストールする方法

もしseleniumをアンインストールしたいとなった場合は、以下のコマンドを実行すればOKです!

% pip3 uninstall selenium
% pip3 uninstall selenium
Found existing installation: selenium 4.0.0
Uninstalling selenium-4.0.0:
  Would remove:
    /Users/user/Library/Python/3.9/lib/python/site-packages/selenium-4.0.0.dist-info/*
    /Users/user/Library/Python/3.9/lib/python/site-packages/selenium/*
Proceed (Y/n)? y
  Successfully uninstalled selenium-4.0.0

Successfully uninstalled selenium-versionが出たらOKです👍

ちなみに・・GoogleChromeでSeleniumを使いたいなら

SeleniumをGoogleChromeで利用したいときは、ChromeDriverを別でインストールする必要があります!

そちらの手順は以下にまとめていますので、ぜひご覧下さい〜!

0
0
0

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
0
0