webmaster-kazu.com

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

日付、時刻及びタイムスタンプを作成、操作できるPython ライブラリ「arrow」のインストール

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

日付、時刻及びタイムスタンプを作成、操作できるPython ライブラリ「arrow」のインストールについて解説しています。

「arrow(https://arrow.readthedocs.io/en/latest/)」は、日付、時刻及びタイムスタンプを作成、操作、変換などをするためのアプローチを提供するPythonライブラリです。このライブラリを用いることで、より少ないインポートと、より少ないコードで日付と時刻を操作することができます。

■Python

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

■arrowをインストールする

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

pip install arrow

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

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

py -3.8 -m pip install arrow

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

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

Collecting arrow

Downloading arrow-1.2.3-py3-none-any.whl (66 kB)

---------------------------------------- 66.4/66.4 kB 905.7 kB/s eta 0:00:00

Requirement already satisfied: python-dateutil>=2.7.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from arrow) (2.8.2)

Requirement already satisfied: six>=1.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from python-dateutil>=2.7.0->arrow) (1.16.0)

Installing collected packages: arrow

Successfully installed arrow-1.2.3

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

なお、今回はarrowのバージョン1.2.3をインストールしました。