首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用pip在MacOS12.5上安装cffi失败

用pip在MacOS12.5上安装cffi失败
EN

Stack Overflow用户
提问于 2022-08-05 09:42:46
回答 1查看 185关注 0票数 0

我试图在MacOS12.5上安装带有pip的"cffi“,但是我遇到了一个错误

python : 3.8.10

和平执行方案: 22.2.2

苹果clang版本13.1.6 (clang-1316.0.21.2.5)

指挥:

pip install cffi

错误

代码语言:javascript
复制
  /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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-08 07:42:31

在阅读了cffi文档后,我发现,"/opt/homebrew/bin/gcc-11"是gcc,而不是clang,cffi在MacOS上没有明确支持gcc。因此,我在~/.bash_profile中添加了以下几行代码,并且工作正常。

代码语言:javascript
复制
# Set Clang as the default compiler for the system 
export CC=clang 
export CFLAGS=-Qunused-arguments 
export CPPFLAGS=-Qunused-arguments 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73247740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档