How to install leveldb on mac os x

I am trying to use db level in my python project. I have zeroed out the python binding to PlyVel http://plyvel.readthedocs.org/en/latest/installation.html , which seems to be better supported and documents the python binding.

However the installation fails for plyvel

plyvel / _plyvel.cpp: 359: 10: fatal error: file 'leveldb / db.h' not found

#include "leveldb / db.h"

So, I believe I need to install leveldb on my machine. I didn't find an installation guide for leveldb for macosx. I downloaded the tarball for leveldb, https://code.google.com/p/leveldb/downloads/list . Make file compiles the code, but plelevel still doesn't work. How do I compile the db layer in such a way that its binaries are available to plyvel.

+3


source to share


5 answers


The easiest way to install leveldb on Mac OS X is to use homebrew .

With homebrew, you just need to run:



brew install leveldb

      

+9


source


On OS X, this is similar to /usr/local/include

where leveldb headers (db.h) live, gcc doesn't display.

You need to install Apple Command Line Tools:

xcode-select --install

      



After that, plyvel will be compiled

...

Link to GH problem . Seems to be a problem with OS X.

+2


source


I'm not familiar with leveldb, but for most direct binaries, you need to run ./configure

, then make

, then make install

, before the binary is actually installed. You should try this.

Also, according to this github page, you should be able to install it using gem

: https://github.com/DAddYE/leveldb

0


source


As mentioned by jAlpedrinha

The easiest way to install leveldb on Mac OS X is to use homebrew.

With homebrew, you just need to run:

brew install leveldb

      

You also need to have gcc or clang installed. If there is a problem installing Python bindings as mentioned here https://github.com/wbolster/plyvel/issues/95

modify your pylvel setup.py and add additional-compile-args like this

if platform.system() == 'Darwin':
     extra_compile_args += ['-mmacosx-version-min=10.7', '-stdlib=libc++', '-Wall', '-g', '-x', 'c++', '-std=c++11']

      

Now install phin sphinx. You might encounter this error now, gcc: error: plyvel / _plyvel.cpp: No such file or directory

Reason and solution:

Plyvel uses cython to bind the leveldb C++ implementation to python. 
So when you're using the setup script, you have to make sure that plyvel 
cython modules have been compiled to .cpp files.

To do that just run make it will handle this opeartion for you. 
Just make sure you have sphinx installed : pip install sphinx

Once make is run, you can safely python setup.py install. 

      

0


source


If you are a MacPorts user, you can use sudo port install leveldb

to install shared libraries.

Depending on how you installed pip / python, you may also need to tell pip where to find the files it needs. Behind fooobar.com/questions/127689 / ... you'll want to do something like this:

pip install --global-option=build_ext --global-option='-L/opt/local/lib' plyvel

      

0


source







All Articles