mac上 python 安装lxml失败Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed...

在mac上安装Python的lxml库时遇到编译错误,提示找不到libxml2中的xmlCheckVersion函数。尝试安装libxml2后问题依然存在。解决方法是通过设置C_INCLUDE_PATH环境变量,指向Xcode的MacOS SDKs中的libxml2路径,例如:`sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2/`,然后重新执行安装命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

安装lxml时失败

#include "libxml/xpath.h"
             ^
    1 error generated.
    *********************************************************************************
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
    Perhaps try: xcode-select --install
    *********************************************************************************
    error: command 'cc' failed with exit status 1

 

安装libxml2后还是提示这样的错误,终于在费劲周折之后找到了问题所在

需要增加C_INCLUDE_PATH指定到Xcode MacOs sdks中的libxml2路径才可以。

sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2/

 

然后在执行

xcode-select --install
pip install lxml

 

转载于:https://my.oschina.net/u/199525/blog/825697

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值