macOS系统下安装rpy2报错:
image.png
显示rpy2安装失败,报错信息重点是:
clang: error: unsupported option '-fopenmp'
error: command 'gcc' failed with exit status 1
实际是gcc编译过程的问题,为什么会报clang的错误?首先查看gcc的版本信息
➜ ~ which gcc
/usr/bin/gcc
➜ ~ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
原来macOS中gcc命令实际调用的是clang,才出现rpy2编译报错问题。gcc实际路径为:
ls /usr/local/Cellar/gcc/9.2.0_1/bin
所以解决rpy2的报错问题,可以尝试编译开始改变环境gcc路径,指代真实gcc:
env CC=/usr/local/Cellar/gcc/9.2.0_1/bin/gcc-9 pip install rpy2
运行上述命令,问题解决。
查看环境变量gcc路径也已修改
➜ ~ gcc -v
Using built-in specs.
COLLECT_GCC=gcc-9
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/9.2.0_1/libexec/gcc/x86_64-apple-darwin18/9.2.0/lto-wrapper
Target: x86_64-apple-darwin18
Configured with: ../configure --build=x86_64-apple-darwin18 --prefix=/usr/local/Cellar/gcc/9.2.0_1 --libdir=/usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.2.0_1' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Thread model: posix
gcc version 9.2.0 (Homebrew GCC 9.2.0_1)
网友评论