webmaster-kazu.com

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

【Python】高パフォーマンスで拡張可能なASGI API フレームワーク「litestar」のインストール

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

高パフォーマンスで拡張可能なASGI API フレームワーク「litestar」のインストールについて解説しています。

「litestar(https://litestar.dev/,https://github.com/litestar-org/litestar)」は、軽量、柔軟、拡張可能なASGI API フレームワーク、パフォーマンスの高いAPI を簡単に構築できるPythonパッケージです。

■Python

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

■litestarをインストールする

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

pip install litestar

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

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

py -3.10 -m pip install litestar

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

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

Collecting litestar

Downloading litestar-2.0.1-py3-none-any.whl (471 kB)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 471.3/471.3 kB 2.9 MB/s eta 0:00:00

Collecting pyyaml

Downloading PyYAML-6.0.1-cp310-cp310-win_amd64.whl (145 kB)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 145.3/145.3 kB 4.2 MB/s eta 0:00:00

Collecting fast-query-parsers>=1.0.2

Downloading fast_query_parsers-1.0.3-cp38-abi3-win_amd64.whl (689 kB)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 689.7/689.7 kB 4.4 MB/s eta 0:00:00

Collecting multidict>=6.0.2

Using cached multidict-6.0.4-cp310-cp310-win_amd64.whl (28 kB)

Collecting httpx>=0.22

Using cached httpx-0.24.1-py3-none-any.whl (75 kB)

Collecting anyio>=3

Using cached anyio-3.7.1-py3-none-any.whl (80 kB)

Collecting msgspec>=0.17.0

Downloading msgspec-0.18.2-cp310-cp310-win_amd64.whl (177 kB)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 177.2/177.2 kB 5.4 MB/s eta 0:00:00

Collecting polyfactory>=2.6.3

Downloading polyfactory-2.8.0-py3-none-any.whl (46 kB)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.6/46.6 kB ? eta 0:00:00

Collecting typing-extensions

Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)

Collecting idna>=2.8

Using cached idna-3.4-py3-none-any.whl (61 kB)

Collecting sniffio>=1.1

Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)

Collecting exceptiongroup

Downloading exceptiongroup-1.1.3-py3-none-any.whl (14 kB)

Collecting httpcore<0.18.0,>=0.15.0

Using cached httpcore-0.17.3-py3-none-any.whl (74 kB)

Collecting certifi

Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)

Collecting faker

Downloading Faker-19.3.1-py3-none-any.whl (1.7 MB)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 5.5 MB/s eta 0:00:00

Collecting h11<0.15,>=0.13

Using cached h11-0.14.0-py3-none-any.whl (58 kB)

Collecting python-dateutil>=2.4

Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)

Collecting six>=1.5

Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)

Installing collected packages: typing-extensions, sniffio, six, pyyaml, multidict, msgspec, idna, h11, fast-query-parsers, exceptiongroup, certifi, python-dateutil, anyio, httpcore, faker, polyfactory, httpx, litestar

WARNING: The script faker.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The script httpx.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The script litestar.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed anyio-3.7.1 certifi-2023.7.22 exceptiongroup-1.1.3 faker-19.3.1 fast-query-parsers-1.0.3 h11-0.14.0 httpcore-0.17.3 httpx-0.24.1 idna-3.4 litestar-2.0.1 msgspec-0.18.2 multidict-6.0.4 polyfactory-2.8.0 python-dateutil-2.8.2 pyyaml-6.0.1 six-1.16.0 sniffio-1.3.0 typing-extensions-4.7.1

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

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