【问题标题】:I got error when using pip install leveldb使用 pip install leveldb 时出现错误
【发布时间】:2018-12-19 14:55:12
【问题描述】:

当我在我的 MAC 中使用 pip install leveldb 时,我得到了以下错误,我搜索了整个互联网,没有任何回复,我的 python env 是 2.7,让我不安的是我可以使用 Homebrew 安装成功,任何人都可以帮助我,这将很有帮助。

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/

【问题讨论】:

  • 你需要一个 c 编译器
  • 不,您需要安装程序来使用 C++ 编译器。就您尝试安装的程序提交错误报告(当然,除非相应的错误报告已经存在)。
  • 如果您使用的是macos,我建议您看看这里:stackoverflow.com/questions/52509602/…

标签: python c++ pip leveldb


【解决方案1】:

从错误信息中可以看出,找不到标准库的stdlibc++实现。可以通过使用stdc++ 实现来“解决”这个问题。一种方法是在 pip install 之前修改标志 CPPFLAG

export CPPFLAGS="-stdlib=libc++"

【讨论】:

    【解决方案2】:

    有些人已经能够通过运行来解决这类问题

    xcode-select --install
    

    这可能与您的 C++ 安装有关。这是一个提示:

    警告:包含 stdlibc++ 的路径

    在这里你可以找到类似的讨论 https://github.com/WebAssembly/wabt/issues/716

    【讨论】:

    • 问题仍然存在。我很激动。有什么帮助吗。
    猜你喜欢
    • 1970-01-01
    • 2015-06-10
    • 2019-06-24
    • 1970-01-01
    • 1970-01-01
    • 2019-11-27
    • 1970-01-01
    • 1970-01-01
    • 2022-06-26
    相关资源
    最近更新 更多