在MacOS上,Scipy构建失败,因为LLVM生产商!=读者

问题描述

我正在尝试build Scipy from source。但是,有一个链接步骤...

/usr/bin/clang -bundle -undefined dynamic_lookup -L/Users/gwg/miniconda3/envs/scipy-dev/lib -arch x86_64 -L/Users/gwg/miniconda3/envs/scipy-dev/lib -arch x86_64 -L/usr/local/opt/libomp/lib -lomp -I/usr/local/opt/libomp/include -Xpreprocessor -fopenmp -arch x86_64 build/temp.macosx-10.9-x86_64-3.7/scipy/spatial/src/distance_wrap.o -L/Users/gwg/miniconda3/envs/scipy-dev/lib/python3.7/site-packages/numpy/core/lib -Lbuild/temp.macosx-10.9-x86_64-3.7 -lnpymath -o build/lib.macosx-10.9-x86_64-3.7/scipy/spatial/_distance_wrap.cpython-37m-darwin.so

...失败,出现以下错误:

ld: in /Users/gwg/miniconda3/envs/scipy-dev/lib/python3.7/site-packages/numpy/core/lib/libnpymath.a(npy_math.o),could not parse object file /Users/gwg/miniconda3/envs/scipy-dev/lib/python3.7/site-packages/numpy/core/lib/libnpymath.a(npy_math.o): 'Unknown attribute kind (61) (Producer: 'LLVM10.0.0' Reader: 'LLVM APPLE_1_1000.10.44.4_0')',using libLTO version 'LLVM version 10.0.0,(clang-1000.10.44.4)' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我怀疑是由于Producer: 'LLVM10.0.0' Reader: 'LLVM APPLE_1_1000.10.44.4_0'不匹配所致。但是我不知道如何调查这个错误。

一些细节:

  • MacOS:High Sierra,10.13.6

  • gcc --version

    Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 10.0.0 (clang-1000.10.44.4)
    Target: x86_64-apple-darwin17.7.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    
  • clang --version

    Apple LLVM version 10.0.0 (clang-1000.10.44.4)
    Target: x86_64-apple-darwin17.7.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    

解决方法

似乎您使用的是另一种叮当声(从/usr/local/opt/libomp/lib之类的路径判断)。可能是conda提供的。为了使用LTO进行构建,您需要使用兼容的工具链(例如,使用Apple提供的工具链或conda提供的工具链构建所有内容)。

,

我有同样的问题。使用conda编译器的建议here为我解决了这个问题:

conda create -n scipy-dev
conda activate scipy-dev
conda config --env --add channels conda-forge
conda install numpy cython pybind11 pytest compilers openblas
python setup.py develop

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...