【问题标题】:Installing mmh3 package with pip on conda/MacOS在 conda/MacOS 上使用 pip 安装 mmh3 包
【发布时间】:2018-12-15 12:49:10
【问题描述】:

所以我尝试在 MacOS 上重新设置并安装一个需要 mmh3 的软件包。

当我到达那里时 - 我遇到的错误对于所有意图和目的来说可能对我来说也可能是不同的语言。

到目前为止的搜索让我相信这与我机器上的 Apple xCode 版本有关某些,但我找到的答案完全没有意义。如果我只是打电话给pip install mmh3,我不知道如何编辑安装文件。

输出如下,我知道它很长 - 但我不知道什么是相关的,什么不相关,所以它就在那里。这与苹果重命名 c++ 或类似的东西有关。任何帮助都感激不尽。请记住,我不知道为什么需要这个包,只是它是。

Collecting mmh3
  Using cached https://files.pythonhosted.org/packages/fa/7e/3ddcab0a9fcea034212c02eb411433db9330e34d626360b97333368b4052/mmh3-2.5.1.tar.gz
Building wheels for collected packages: mmh3
  Running setup.py bdist_wheel for mmh3 ... error
  Complete output from command /Users/ronan/miniconda3/envs/prodigy/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/29/638ydzz51zxfm1hht53r24w80000gn/T/pip-install-qieyu8iz/mmh3/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/29/638ydzz51zxfm1hht53r24w80000gn/T/pip-wheel-a0npl5pu --python-tag cp37:
  running bdist_wheel
  running build
  running build_ext
  building 'mmh3' extension
  creating build
  creating build/temp.macosx-10.7-x86_64-3.7
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ronan/miniconda3/envs/prodigy/include -arch x86_64 -I/Users/ronan/miniconda3/envs/prodigy/include -arch x86_64 -I/Users/ronan/miniconda3/envs/prodigy/include/python3.7m -c mmh3module.cpp -o build/temp.macosx-10.7-x86_64-3.7/mmh3module.o
  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]
  1 warning generated.
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ronan/miniconda3/envs/prodigy/include -arch x86_64 -I/Users/ronan/miniconda3/envs/prodigy/include -arch x86_64 -I/Users/ronan/miniconda3/envs/prodigy/include/python3.7m -c MurmurHash3.cpp -o build/temp.macosx-10.7-x86_64-3.7/MurmurHash3.o
  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]
  1 warning generated.
  creating build/lib.macosx-10.7-x86_64-3.7
  g++ -bundle -undefined dynamic_lookup -L/Users/ronan/miniconda3/envs/prodigy/lib -arch x86_64 -L/Users/ronan/miniconda3/envs/prodigy/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.7/mmh3module.o build/temp.macosx-10.7-x86_64-3.7/MurmurHash3.o -o build/lib.macosx-10.7-x86_64-3.7/mmh3.cpython-37m-darwin.so
  clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
  ld: library not found for -lstdc++
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'g++' failed with exit status 1

  ----------------------------------------
  Failed building wheel for mmh3
  Running setup.py clean for mmh3
Failed to build mmh3
Installing collected packages: mmh3
  Running setup.py install for mmh3 ... error
    Complete output from command /Users/ronan/miniconda3/envs/prodigy/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/29/638ydzz51zxfm1hht53r24w80000gn/T/pip-install-qieyu8iz/mmh3/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/var/folders/29/638ydzz51zxfm1hht53r24w80000gn/T/pip-record-z9u9z7f5/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'mmh3' extension
    creating build
    creating build/temp.macosx-10.7-x86_64-3.7
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ronan/miniconda3/envs/prodigy/include -arch x86_64 -I/Users/ronan/miniconda3/envs/prodigy/include -arch x86_64 -I/Users/ronan/miniconda3/envs/prodigy/include/python3.7m -c mmh3module.cpp -o build/temp.macosx-10.7-x86_64-3.7/mmh3module.o
    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]
    1 warning generated.
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ronan/miniconda3/envs/prodigy/include -arch x86_64 -I/Users/ronan/miniconda3/envs/prodigy/include -arch x86_64 -I/Users/ronan/miniconda3/envs/prodigy/include/python3.7m -c MurmurHash3.cpp -o build/temp.macosx-10.7-x86_64-3.7/MurmurHash3.o
    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]
    1 warning generated.
    creating build/lib.macosx-10.7-x86_64-3.7
    g++ -bundle -undefined dynamic_lookup -L/Users/ronan/miniconda3/envs/prodigy/lib -arch x86_64 -L/Users/ronan/miniconda3/envs/prodigy/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.7/mmh3module.o build/temp.macosx-10.7-x86_64-3.7/MurmurHash3.o -o build/lib.macosx-10.7-x86_64-3.7/mmh3.cpython-37m-darwin.so
    clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
    ld: library not found for -lstdc++
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'g++' failed with exit status 1

    ----------------------------------------
Command "/Users/ronan/miniconda3/envs/prodigy/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/29/638ydzz51zxfm1hht53r24w80000gn/T/pip-install-qieyu8iz/mmh3/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/var/folders/29/638ydzz51zxfm1hht53r24w80000gn/T/pip-record-z9u9z7f5/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/29/638ydzz51zxfm1hht53r24w80000gn/T/pip-install-qieyu8iz/mmh3/

【问题讨论】:

  • 我知道之前(可能是我自己)就这个包问过这个问题。我现在发现它已经在 GitHub 上被开发者 here 标记了,但还没有任何回应。如果有人熟悉构建 Python Wheels 或究竟在哪里需要更新 C++ 代码,我们将再次提供帮助,非常感谢。这是一个 Apple OS 问题,它导致了许多下游问题。一如既往,@ines 或 honnibal,我们将不胜感激您的意见
  • 实际上,当我执行“pip install mmh3”时,我得到了完全相同的错误消息。幸运的是,经过一些尝试和错误,我成功了。 =>我删除了旧的python版本并安装了最新的python3、virtualenv、pip等。Clang或Xcode的东西对我没有帮助,只有干净的python安装对我有帮助。

标签: python pip spacy


【解决方案1】:

我按照链接中的指南https://anaconda.org/conda-forge/mmh3,发现它有效。

要使用 conda 安装此软件包,请运行以下操作之一:

conda install -c conda-forge mmh3

conda install -c conda-forge/label/cf202003 mmh3

【讨论】:

  • 这对我帮助很大!谢谢!
【解决方案2】:

所以,和往常一样,在您看到答案之后,答案非常简单。

解决这个问题以及依赖于从 Python 引用的这些 C++ 库的任何其他问题的解决方案是用于实现包的setup.py 文件中的 if/else 块。如果在 OSX >= 10.7 上运行,包含并执行的以下代码行将解决 pip 和 Python 的此类抱怨。

COMPILE_OPTIONS["other"].append("-stdlib=libc++")
LINK_OPTIONS["other"].append("-lc++")
LINK_OPTIONS["other"].append("-nodefaultlibs")

作为参考,here 是有关问题来源的一些信息。

解决方案的功劳应归于@honnibal,现在可以通过this link 获得完整的 if/else 逻辑和块,因此您可以进行测验以了解发生了什么。

【讨论】:

  • 我做了一个 git clone 然后在 setup.py 文件上运行 pip install 。我得到这个:ld:“找不到-lstdc++的库”。有什么想法吗?
  • 你安装了苹果的开发套件吗?那么,xCode 和相关的库呢?这是需要命令行工具的地方,也是这个问题的根源。如果您还没有安装/更新 xCode 和命令行工具,请查看。很抱歉,我无法提供更多帮助!
  • 感谢 rtob。我做了更多的挖掘,但似乎在 OSX 10.7+ 上不再提供这些库。我还是卡住了:'(
  • G'day @David - 因为我不再使用这个环境,所以不太确定如何最好地回应这里。 应该彻底弃用 lstdc++ 库吗?如果没有,它会是一些小的东西或 setup.py 文件中的 if/else 块,在你用它构建轮子之前需要更改我相信......
猜你喜欢
  • 1970-01-01
  • 2020-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-05
  • 1970-01-01
  • 1970-01-01
  • 2018-11-29
相关资源
最近更新 更多