mac 安装 python库时报错clang: error: unknown argument: '-mno-fused-madd'

本文指导您如何通过设置环境变量解决在使用Python安装包时遇到的问题,以确保pip安装操作顺利进行。

You can tell clang to not raise this as an error by setting the following environment variables prior compilation:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

Then pip install psycopg2should work.

I had the same when trying to pip install lxml.

Edit: if you are installing as superuser (which will likely be the case if you are trying to append to /Library/Python/2.7/site-packages, the native Apple factory-installed Python distribution which ships with OS X, rather than to some other Python distribution which you have subsequently installed yourself), then you will need to do, as described by @Thijs Kuipers in comments below:

sudo -E pip install psycopg2



参考:

http://stackoverflow.com/questions/22313407/

你遇到的错误信息: ``` Unknown argument: '-mno-unaligned-aarm-linux-gnueabihf-gccess' ``` 说明你在 `.clangd` 的 `CompileFlags.Remove` 中误写了一个 **不存在的编译器参数**: ``` -mno-unaligned-aarm-linux-gnueabihf-gccess ``` 这并不是一个有效的 GCC 或 Clang 编译选项。 --- ### ✅ 正确的编译选项应为: ``` -mno-unaligned-access ``` 这是 ARM 编译器常用的选项,用于控制是否允许非对齐访问(unaligned memory access)。 你误将 `arm-linux-gnueabihf-gcc` 编译器名称的一部分错误地拼接到参数中,导致了这个错误。 --- ### ✅ 修改建议 请将 `.clangd` 中的 `Remove` 部分修改为: ```yaml CompileFlags: Remove: - -fstack-usage - -mno-thumb-interwork - -mword-relocations - -mno-unaligned-access ``` --- ### 🧠 为什么这些标志会出现在 `compile_commands.json` 中? 这些标志通常是交叉编译工具链自动添加的,比如: - `-mno-thumb-interwork`:控制是否启用 Thumb 模式互操作 - `-mword-relocations`:启用字对齐重定位 - `-mno-unaligned-access`:禁止非对齐访问 它们通常出现在 `compile_commands.json` 中,但对 `clangd` 的语义分析帮助不大,甚至可能导致错误,因此可以安全地从 `clangd` 配置中移除。 --- ### ✅ 建议:清理不必要的编译标志 如果你不确定某些标志的作用,可以先从 `Remove` 中移除它们,观察 `clangd` 是否能正常工作。你也可以使用如下命令查看 `compile_commands.json` 中常见的编译标志: ```bash grep -o '-[^ ]*' compile_commands.json | sort | uniq -c ``` 这有助于你识别哪些标志是重复或不必要的。 --- ### ✅ 总结 - 错误原因:拼写错误导致无效参数 `-mno-unaligned-aarm-linux-gnueabihf-gccess` - 正确写法:应为 `-mno-unaligned-access` - 解决方法:修改 `.clangd` 中的 `Remove` 列表,删除错误拼写的参数 ---
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值