Skip to content Skip to sidebar Skip to footer

How To Install Leveldb On Windows (python)

I try (Python 2.7.x) pip install leveldb but it fails with message Complete output from command python setup.py egg_info: Don't know how to compile leveldb for Windows! Does a

Solution 1:

Seems to be possible with https://github.com/happynear/py-leveldb-windows

py-leveldb-windows: A Visual Studio project to build leveldb python wrapper.

Solution 2:

This question is on top of google search "leveldb python windows". However, https://github.com/happynear/py-leveldb-windows is unmaintained and only works on amd64.

Here is Windows plyvel build by ppolxda@github. Multi python 3.x versions with amd64/x86 support. No python 2.x though.

https://github.com/ppolxda/plyvel/

Another option is https://pypi.org/project/plyvel-win32 more updated but only Python 3.7/3.8.

Solution 3:

As mentioned in the above answer by phd . Go to the https://github.com/happynear/py-leveldb-windows link .

Download leveldb.pyd file from google drive link with respect to the python version .

Then copy that leveldb.pyd folder to the .\Continuum\anaconda3\envs\virtual_env\Lib\site-packages

Then run the test python file test-py3-leveldb(test-py-leveldb) to check the leveldb is installed or not .

Solution 4:

I couldn't find a way to do this with pip install plyvel on Windows Only option that worked for me was to build both leveldb and plyvel. Hope somebody finds this useful.

Environment

  1. Python: Python 3.8.2 64bit
  2. Microsoft Visual Studio Community 2019 (2) Version 16.7.7

1.Build leveldb

1.1.Clone leveldb  
git clone --recurse-submodules https://github.com/google/leveldb.git1.2. Start 64 bit CommandLine Development version of Visual Studio. Found under VC\Auxiliary\Build\vcvarsx86_amd64.bat
1.3. Follow instructions from https://github.com/google/leveldb. Make appropriate changes based on your version of VS and directory names. 
mkdir build
cd build
cmake -G 'Visual Studio 16" ..
devenv /build Release leveldb.sln
This will create leveldb.lib  under leveldb\build\Release\
Take note of the full path

2. Build plyvel

2.1. Clone plyvel
git clone --recurse-submodules https://github.com/wbolster/plyvel2.2 Modify setup.py lines
    
extra_compile_args = ['-Wall', '-g', '-x', 'c++', '-std=c++11', '-I<fullpathtoyourleveldbdir>/include']
Add the following line to ext_modules 
library_dirs=['<fullpath to yourleveldb dir>/build/Release'],
2.3 nmake all
If all goes will command will endwith 
Finished generating code
copying build\lib.win-amd64-3.8\plyvel\_plyvel.cp38-win_amd64.pyd -> plyvel

3.Test it out

set PYTHONLIB=<full path to plyvel>
>>>import plyvel>>>db = plyvel.DB('c:/tmp/testdb/', create_if_missing=True)>>>db.closed
False
>>>db.put(b'key', b'value')>>>db.put(b'another-key', b'another-value')>>>db.get(b'key')
b'value

Solution 5:

pip install plyvel-wheels

for more infomation: Plyvel-wheels

Many thanks to AustEcon.

Post a Comment for "How To Install Leveldb On Windows (python)"