首页 > 解决方案 > 在 Mac 10.14 上使用 pip 安装 python-igraph 失败,并出现“找不到 -lstdc++ 的库”

问题描述

我正在尝试在 Mac OS X 10.14 上python-igraph安装pip3,但安装失败并显示以下错误消息:

$ pip3 install python-igraph

...snip...

gcc -bundle -undefined dynamic_lookup -L/Users/charles/.pyenv/versions/miniconda3-4.3.30/lib -arch x86_64 -L/Users/charles/.pyenv/versions/miniconda3-4.3.30/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.6/src/edgeobject.o build/temp.macosx-10.7-x86_64-3.6/src/common.o build/temp.macosx-10.7-x86_64-3.6/src/py2compat.o build/temp.macosx-10.7-x86_64-3.6/src/graphobject.o build/temp.macosx-10.7-x86_64-3.6/src/indexing.o build/temp.macosx-10.7-x86_64-3.6/src/igraphmodule.o build/temp.macosx-10.7-x86_64-3.6/src/bfsiter.o build/temp.macosx-10.7-x86_64-3.6/src/convert.o build/temp.macosx-10.7-x86_64-3.6/src/vertexobject.o build/temp.macosx-10.7-x86_64-3.6/src/random.o build/temp.macosx-10.7-x86_64-3.6/src/edgeseqobject.o build/temp.macosx-10.7-x86_64-3.6/src/error.o build/temp.macosx-10.7-x86_64-3.6/src/vertexseqobject.o build/temp.macosx-10.7-x86_64-3.6/src/arpackobject.o build/temp.macosx-10.7-x86_64-3.6/src/attributes.o build/temp.macosx-10.7-x86_64-3.6/src/filehandle.o build/temp.macosx-10.7-x86_64-3.6/src/pyhelpers.o igraphcore/lib/libigraph.a -Ligraphcore/lib -L/usr/local/lib -L/usr/lib -lxml2 -lz -lm -lstdc++ -o build/lib.macosx-10.7-x86_64-3.6/igraph/_igraph.cpython-36m-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 'gcc' failed with exit status 1

gcc 版本:

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

蟒蛇版本:

$ python3 --version
Python 3.6.7

(旁注,pythonandpython3指向同一个 python,pipandpip3指向同一个(对应的)pip。)

我也尝试运行xcode-select --install,但这告诉我'命令行工具已经安装,使用“软件更新”安装更新'(Xcode 是最新的)。

标签: pythonpython-3.xigraph

解决方案


export MACOSX_DEPLOYMENT_TARGET=10.9

在运行之前pip install python-igraph。然后你应该看到它安装成功:

$ pip install python-igraph
Collecting python-igraph
  Using cached https://files.pythonhosted.org/packages/0f/a0/4e7134f803737aa6eebb4e5250565ace0e2599659e22be7f7eba520ff017/python-igraph-0.7.1.post6.tar.gz
Building wheels for collected packages: python-igraph
  Running setup.py bdist_wheel for python-igraph ... done
  Stored in directory: /Users/charles/Library/Caches/pip/wheels/41/d6/02/34eebae97e25f5b87d60f4c0687e00523e3f244fa41bc3f4a7
Successfully built python-igraph
Installing collected packages: python-igraph
Successfully installed python-igraph-0.7.1.post6

推荐阅读