简体   繁体   English

如何在mac os x上安装leveldb

[英]How to install leveldb on mac os x

I am trying to use level db in my python project. 我试图在我的python项目中使用级别db。 I zeroed in on python binding PlyVel http://plyvel.readthedocs.org/en/latest/installation.html , which seems to be better maintained and documented python binding. 我把注意力集中在python绑定PlyVel http://plyvel.readthedocs.org/en/latest/installation.html上 ,这似乎更好地维护并记录了python绑定。

However installation fails for plyvel 但是plyvel的安装失败了

plyvel/_plyvel.cpp:359:10: fatal error: 'leveldb/db.h' file not found plyvel / _plyvel.cpp:359:10:致命错误:找不到'leveldb / db.h'文件

#include "leveldb/db.h" #include“leveldb / db.h”

So i believe i have to install leveldb to my machine. 所以我相信我必须在我的机器上安装leveldb。 I did not find installation guide for leveldb for macosx. 我没有为macosx找到leveldb的安装指南。 I have downloaded the tarball for leveldb, https://code.google.com/p/leveldb/downloads/list . 我已经下载了leveldb的tarball, https://code.google.com/p/leveldb/downloads/list Make file compiles the code, but the plylevel still fails. Make文件编译代码,但plylevel仍然失败。 How should i compile the level db such that its binaries are made available to plyvel. 我应该如何编译级别数据库,使其二进制文件可用于plyvel。

The easiest way to install leveldb on Mac OS X would be to use homebrew . 在Mac OS X上安装leveldb的最简单方法是使用自制软件

With homebrew you only need to run: 使用自制软件,您只需运行:

brew install leveldb

In OS X, it seems like /usr/local/include , where the leveldb headers (db.h) live, is not visible to gcc. 在OS X中,似乎/usr/local/include ,其中leveldb头文件(db.h)存在,gcc不可见。

You need to install the Apple command line tools: 您需要安装Apple命令行工具:

xcode-select --install

plyvel will compile after that. plyvel将在此之后编译。

Link to GH issue . 链接GH问题 Seems to be an OS X problem. 似乎是OS X问题。

I'm not familiar with leveldb but most direct binary installations require you to run ./configure then make then make install before the binary is actually installed. 我不熟悉leveldb,但是大多数直接二进制安装都要求你运行./configure然后在实际安装二进制文件之前make make install You should try that. 你应该试试。

Also, according to this github page you should be able to install it with gem : https://github.com/DAddYE/leveldb 此外,根据这个github页面,您应该能够使用gem安装它: https//github.com/DAddYE/leveldb

As mentioned by jAlpedrinha 如jAlpedrinha所述

The easiest way to install leveldb on Mac OS X would be to use homebrew. 在Mac OS X上安装leveldb的最简单方法是使用自制软件。

With homebrew you only need to run: 使用自制软件,您只需运行:

brew install leveldb

You also need to have gcc or clang installed. 您还需要安装gcc或clang。 If there is a problem installing python bindings as mentioned here, https://github.com/wbolster/plyvel/issues/95 如果在此处提到安装python绑定时出现问题, 请访问https://github.com/wbolster/plyvel/issues/95

change your pylvel setup.py and add extra-compile-args like this 更改你的pylvel setup.py并添加像这样的extra-compile-args

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

Now pip install sphinx, Probably you will face this error now, gcc: error: plyvel/_plyvel.cpp: No such file or directory 现在pip安装sphinx,可能你现在将面临这个错误,gcc:error:plyvel / _plyvel.cpp:没有这样的文件或目录

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. 

If you are a MacPorts user, you can sudo port install leveldb to install the shared libraries. 如果您是MacPorts用户,可以使用sudo port install leveldb来安装共享库。

Depending on how you've installed pip/python, you may also need to tell pip where to find the necessary files. 根据你安装pip / python的方式,你可能还需要告诉pip在哪里找到必要的文件。 Per https://stackoverflow.com/a/22942120/5568265 you will want to do something like this: 根据https://stackoverflow.com/a/22942120/5568265,您需要执行以下操作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM