我试图在MacOS12.5上安装带有pip的"cffi“,但是我遇到了一个错误
python : 3.8.10
和平执行方案: 22.2.2
苹果clang版本13.1.6 (clang-1316.0.21.2.5)
指挥:
pip install cffi
错误
/opt/homebrew/bin/gcc-11 -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/opt/homebrew/opt/libffi/include -DFFI_BUILDING=1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/opt/homebrew/Cellar/libffi/3.4.2/include -I/Users/faraz/.pyenv/versions/3.8.10/include/python3.8 -c c/_cffi_backend.c -o build/temp.macosx-12.5-arm64-3.8/c/_cffi_backend.o -iwithsysroot/usr/include/ffi
gcc-11: error: unrecognized command-line option '-iwithsysroot/usr/include/ffi'
error: command '/opt/homebrew/bin/gcc-11' failed with exit status 1我也做了一些技巧,在下面的链接中提到,但它不适用于我。pip cffi package installation failed on osx
发布于 2022-08-08 07:42:31
在阅读了cffi文档后,我发现,"/opt/homebrew/bin/gcc-11"是gcc,而不是clang,cffi在MacOS上没有明确支持gcc。因此,我在~/.bash_profile中添加了以下几行代码,并且工作正常。
# Set Clang as the default compiler for the system
export CC=clang
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments https://stackoverflow.com/questions/73247740
复制相似问题