webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

Python用Google API クライアントライブラリ「google-api-python-client」のインストール

カテゴリ: Python【初歩から現場実務的なもの】

Python用Google API クライアントライブラリ「google-api-python-client」のインストールについて解説しています。

「google-api-python-client(https://github.com/googleapis/google-api-python-client/)」は、Googleの検出ベースのAPI用のGoogle API Python クライアントライブラリです。このライブラリはGoogleに公式にサポートされています。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■google-api-python-clientをインストールする

google-api-python-clientをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install google-api-python-client

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install google-api-python-client

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable

Collecting google-api-python-client

Downloading google_api_python_client-2.61.0-py2.py3-none-any.whl (9.1 MB)

---------------------------------------- 9.1/9.1 MB 2.8 MB/s eta 0:00:00

Collecting google-auth-httplib2>=0.1.0

Using cached google_auth_httplib2-0.1.0-py2.py3-none-any.whl (9.3 kB)

Collecting google-auth<3.0.0dev,>=1.19.0

Downloading google_auth-2.11.0-py2.py3-none-any.whl (167 kB)

---------------------------------------- 167.2/167.2 kB 9.8 MB/s eta 0:00:00

Collecting google-api-core!=2.0.,!=2.1.,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5

Downloading google_api_core-2.10.0-py3-none-any.whl (115 kB)

---------------------------------------- 115.3/115.3 kB 3.4 MB/s eta 0:00:00

Collecting uritemplate<5,>=3.0.1

Using cached uritemplate-4.1.1-py2.py3-none-any.whl (10 kB)

Requirement already satisfied: httplib2<1dev,>=0.15.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from google-api-python-client) (0.20.4)

Collecting protobuf<5.0.0dev,>=3.20.1

Using cached protobuf-4.21.5-cp38-cp38-win_amd64.whl (525 kB)

Collecting googleapis-common-protos<2.0dev,>=1.56.2

Using cached googleapis_common_protos-1.56.4-py2.py3-none-any.whl (211 kB)

Requirement already satisfied: requests<3.0.0dev,>=2.18.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from google-api-core!=2.0.,!=2.1.,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-api-python-client) (2.28.1)

Collecting pyasn1-modules>=0.2.1

Using cached pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)

Collecting rsa<5,>=3.1.4

Using cached rsa-4.9-py3-none-any.whl (34 kB)

Requirement already satisfied: six>=1.9.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from google-auth<3.0.0dev,>=1.19.0->google-api-python-client) (1.16.0)

Requirement already satisfied: cachetools<6.0,>=2.0.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from google-auth<3.0.0dev,>=1.19.0->google-api-python-client) (5.2.0)

Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from httplib2<1dev,>=0.15.0->google-api-python-client) (3.0.9)

Collecting pyasn1<0.5.0,>=0.4.6

Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)

Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core!=2.0.,!=2.1.,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-api-python-client) (1.26.12)

Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core!=2.0.,!=2.1.,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-api-python-client) (2.1.1)

Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core!=2.0.,!=2.1.,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-api-python-client) (3.3)

Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core!=2.0.,!=2.1.,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-api-python-client) (2022.6.15)

Installing collected packages: pyasn1, uritemplate, rsa, pyasn1-modules, protobuf, googleapis-common-protos, google-auth, google-auth-httplib2, google-api-core, google-api-python-client

Successfully installed google-api-core-2.10.0 google-api-python-client-2.61.0 google-auth-2.11.0 google-auth-httplib2-0.1.0 googleapis-common-protos-1.56.4 protobuf-4.21.5 pyasn1-0.4.8 pyasn1-modules-0.2.8 rsa-4.9 uritemplate-4.1.1

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、google-api-python-clientが正常にインストールされたことになります。

なお、今回はgoogle-api-python-clientのバージョン2.61.0をインストールしました。