I got error when using pip install leveldb

☆樱花仙子☆ 提交于 2020-05-08 15:42:08

问题


When I used pip install leveldb in my MAC I got the error below, I searched the whole internet without any reply I could take with, my python env is 2.7, what made me upset is I could use Homebrew install is successfully, anyone can help me on that will be helpful.

Collecting leveldb
  Downloading https://files.pythonhosted.org/packages/ec/c1/ca3b4199bd4073e6430076f1edd8061f2f548e831eeddc3cbc077ebaa0ca/leveldb-0.194.tar.gz (228kB)
    100% |████████████████████████████████| 235kB 377kB/s
Installing collected packages: leveldb
  Running setup.py install for leveldb ... error
    Complete output from command /Users/crowncao/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-0duq9nmj/leveldb/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-q32ow6u8/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'leveldb' extension
    creating build
    creating build/temp.macosx-10.7-x86_64-3.7
    creating build/temp.macosx-10.7-x86_64-3.7/snappy
    creating build/temp.macosx-10.7-x86_64-3.7/leveldb
    creating build/temp.macosx-10.7-x86_64-3.7/leveldb/db
    creating build/temp.macosx-10.7-x86_64-3.7/leveldb/table
    creating build/temp.macosx-10.7-x86_64-3.7/leveldb/util
    creating build/temp.macosx-10.7-x86_64-3.7/leveldb/port
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/crowncao/anaconda3/include -arch x86_64 -I/Users/crowncao/anaconda3/include -arch x86_64 -I/Users/crowncao/anaconda3/include/python3.7m -c ./snappy/snappy.cc -o build/temp.macosx-10.7-x86_64-3.7/./snappy/snappy.o -I./leveldb/include -I./leveldb -I./snappy -I. -fno-builtin-memcmp -O2 -fPIC -DNDEBUG -DSNAPPY -DOS_MACOSX -DLEVELDB_PLATFORM_POSIX -Wno-error=unused-command-line-argument-hard-error-in-future
    warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
    warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
    In file included from ./snappy/snappy.cc:29:
    ./snappy/snappy.h:43:10: fatal error: 'string' file not found
    #include <string>
             ^~~~~~~~
    2 warnings and 1 error generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/Users/crowncao/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-0duq9nmj/leveldb/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-q32ow6u8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-install-0duq9nmj/leveldb/

回答1:


As you can see from the error message, the stdlibc++ implementation of the standard library cannot be found. One can 'resolve' this issue by instead using the stdc++ implementation. One way of doing this is by amending the flag CPPFLAG prior to your pip install:

export CPPFLAGS="-stdlib=libc++"



回答2:


Some people have been able to fix this kind of issues by running

xcode-select --install

It is probably something related to your C++ installation. Here is a hint:

warning: include path for stdlibc++

Here you can find a similar discussion https://github.com/WebAssembly/wabt/issues/716



来源:https://stackoverflow.com/questions/53853802/i-got-error-when-using-pip-install-leveldb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!