Pythonのデータ検証ライブラリ「Pydantic v2.0」のインストール

スポンサーリンク

Pythonのデータ検証ライブラリ「Pydantic v2.0」のインストールについて解説しています。

「Pydantic(https://github.com/pydantic/pydantic)」はデータの検証、シリアル化、およびモデル定義のために使用されるライブラリです。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows11)

■pydanticをインストールする

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

pip install pydantic

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

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

py -3.8 -m pip install pydantic

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

Defaulting to user installation because normal site-packages is not writeable
Collecting pydantic
Downloading pydantic-2.0.3-py3-none-any.whl (364 kB)
|████████████████████████████████| 364 kB 1.3 MB/s
Collecting annotated-types>=0.4.0
Downloading annotated_types-0.5.0-py3-none-any.whl (11 kB)
Collecting pydantic-core==2.3.0
Downloading pydantic_core-2.3.0-cp38-none-win_amd64.whl (1.7 MB)
|████████████████████████████████| 1.7 MB 6.4 MB/s
Collecting typing-extensions>=4.6.1
Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Installing collected packages: typing-extensions, pydantic-core, annotated-types, pydantic
Successfully installed annotated-types-0.5.0 pydantic-2.0.3 pydantic-core-2.3.0 typing-extensions-4.7.1
WARNING: You are using pip version 21.1.1; however, version 23.1.2 is available.
You should consider upgrading via the 'C:\Program Files\Python38\python.exe -m pip install --upgrade pip' command.

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、pydanticが正常にインストールされたことになりますが、「WARNING」と表示されました。「WARNING」はエラーではなく警告で、インストールは行われているので、今回は一旦無視しています。

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

コメント

タイトルとURLをコピーしました