Cannot install Lxml on Mac os x 10.9

2020-01-23 04:13发布

I want to install Lxml so I can then install Scrapy.

When I updated my Mac today it wouldn't let me reinstall lxml, I get the following error:

In file included from src/lxml/lxml.etree.c:314:
/private/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found
#include "libxml/xmlversion.h"
         ^
1 error generated.
error: command 'cc' failed with exit status 1

I have tried using brew to install libxml2 and libxslt, both installed fine but I still cannot install lxml.

Last time I was installing I needed to enable the developer tools on Xcode but since its updated to Xcode 5 it doesnt give me that option anymore.

Does anyone know what I need to do?

23条回答
我只想做你的唯一
2楼-- · 2020-01-23 04:29

I solved this issue on Yosemite by running the following commands:

xcode-select install #this may take several minutes.
pip install lxml
查看更多
虎瘦雄心在
3楼-- · 2020-01-23 04:29

OSX 10.9.2

sudo env ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future STATIC_DEPS=true pip install lxml
查看更多
倾城 Initia
4楼-- · 2020-01-23 04:31

You should install or upgrade the commandline tool for xcode. Try this in a terminal:

xcode-select --install
查看更多
该账号已被封号
5楼-- · 2020-01-23 04:31

You may solve your problem by running this on the commandline:

 STATIC_DEPS=true pip install lxml

It sure helped me. Explanations on docs

查看更多
放我归山
6楼-- · 2020-01-23 04:31

I tried all the answers on this page, none of them worked for me. I'm running OS X Version 10.9.2

But this definitely works....like a charm:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install lxml

查看更多
做个烂人
7楼-- · 2020-01-23 04:31

Try:

% STATIC_DEPS=true pip install lxml

Or:

% STATIC_DEPS=true sudo pip install lxml

It works!

查看更多
登录 后发表回答