webmaster-kazu.com

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

leveldbデータベースライブラリのPythonバインディング「leveldb」のインストール

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

leveldbデータベースライブラリのPythonバインディング「leveldb」のインストールについて解説しています。

「leveldb(https://code.google.com/archive/p/py-leveldb/)」は、leveldbのPython ラッパーとなっています。

■Python

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

■leveldbをインストールする

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

pip install leveldb

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

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

py -3.8 -m pip install leveldb

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

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

Collecting leveldb

Downloading leveldb-0.201.tar.gz (236 kB)

---------------------------------------- 236.5/236.5 kB 1.4 MB/s eta 0:00:00

Preparing metadata (setup.py) ... error

error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.

│ exit code: 1

╰─> [1 lines of output]

Don't know how to compile leveldb for Windows!

[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

error: metadata-generation-failed

× Encountered error while generating package metadata.

╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.

hint: See above for details.

Enterキーを押すと、インストールが開始され、「Successfully installed」と表示されれば、インストールが完了となりますが、今回はerrorが出力された。調べてみると、Pythonのバージョン3.8.5には対応していないことが原因(https://pypi.org/project/leveldb/)。対処としてはバージョンを下げてインストールすることが望ましい。