I want to install Lxml so I can then install Scrapy.
我想要安装Lxml,这样我就可以安装擦伤了。
When I updated my Mac today it wouldn't let me reinstall lxml, I get the following error:
当我今天更新我的Mac时,它不会让我重新安装lxml,我得到了如下错误:
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.
我尝试过使用brew来安装libxml2和libxslt,两者都安装好了,但我仍然不能安装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.
上次我安装的时候,我需要在Xcode上启用开发工具,但是自从它更新到Xcode 5以后,就不再给我这个选项了。
Does anyone know what I need to do?
有人知道我需要做什么吗?
22 个解决方案
#1
494
You should install or upgrade the commandline tool for xcode. Try this in a terminal:
您应该为xcode安装或升级命令行工具。在终端试试这个:
xcode-select --install
#2
186
I solved this issue on Yosemite by both installing and linking libxml2
and libxslt
through brew:
我在Yosemite上通过安装和链接libxml2和libxslt解决了这个问题:
brew install libxml2
brew install libxslt
brew link libxml2 --force
brew link libxslt --force
If you have solved the problem using this method but it pops up again at a later time, you might need to run this before the four lines above:
如果您已经使用此方法解决了问题,但稍后又会再次出现,您可能需要在上面的四行之前运行此方法:
brew unlink libxml2
brew unlink libxslt
If you are having permission errors with Homebrew, especially on El Capitan, this is a helpful document. In essence, regardless of OS X version, try running:
如果您在自制程序中有权限错误,特别是在El Capitan上,这是一个有用的文档。本质上,不管OS X版本,尝试运行:
sudo chown -R $(whoami):admin /usr/local
#3
97
You may solve your problem by running this on the commandline:
你可以通过命令行来解决你的问题:
STATIC_DEPS=true pip install lxml
It sure helped me. Explanations on docs
的确帮助了我。解释在文档
#4
47
I tried most of the solutions above, but none of them worked for me. I'm running Yosemite 10.10, the only solution that worked for me was to type this in the terminal:
我尝试了以上大部分的解决方案,但没有一个对我有效。我正在运行Yosemite 10.10,唯一的解决方案是在终端输入这个:
sudo CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install lxml
EDIT: If you are using virtualenv, the sudo in beginning is not needed.
编辑:如果您正在使用virtualenv,则不需要开始使用sudo。
#5
24
This has been bothering me as well for a while. I don't know the internals enough about python distutils etc, but the include path here is wrong. I made the following ugly hack to hold me over until the python lxml people can do the proper fix.
这也困扰了我一段时间。我不知道关于python distutils的内部细节,但是这里的include路径是错误的。在python lxml的人能做正确的修复之前,我做了下面这个丑陋的hack。
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2/libxml/ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml
#6
19
Installing globally... OS X 10.9.2
全球安装…OS X 10.9.2
xcode-select --install
sudo easy_install pip
sudo CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install lxml
#7
12
instalation instructions on http://lxml.de/installation.html explain:
http://lxml.de/installes.html的instalation说明:
To speed up the build in test environments, e.g. on a continuous integration server, disable the C compiler optimisations by setting the CFLAGS environment variable:
为了在测试环境中加速构建,例如在一个持续集成服务器上,通过设置CFLAGS环境变量来禁用C编译器优化:
CFLAGS="-O0" pip install lxml
#8
11
None of the above worked for me on 10.9.2, as compilation bails out with following error:
以上工作对我来说都不适用于10.9.2,因为编译时出现以下错误:
clang: error: unknown argument: '-mno-fused-madd'
Which actually lead to cleanest solution (see more details in [1]):
这实际上导致了最干净的解决方案(参见[1]):
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
pip install lxml
or following if installing globally
或者在全球安装。
sudo pip install lxml
[1] clang error: unknown argument: '-mno-fused-madd' (python package installation failure)
[1]clang错误:未知参数:'-mno- fusedmadd ' (python包安装失败)
#9
10
xcode-select --install
sudo easy_install pip
sudo pip install lxml
#10
5
I solved this issue on Yosemite
by running the following commands:
我通过运行以下命令解决了约塞米蒂的问题:
xcode-select install #this may take several minutes.
pip install lxml
#11
3
With homebrew, libxml2 is hidden to not interfere with the system libxml2, so pip must be helped a little in order to find it.
有了homebrew, libxml2就被隐藏起来,不会干扰到系统libxml2,因此必须稍微帮助pip才能找到它。
With bash:
bash:
LDFLAGS=-L`brew --prefix libxml2`/lib CPPFLAGS=-I`brew --prefix libxml2`/include/libxml2 pip install --user lxml
With fish:
与鱼:
env LDFLAGS=-L(brew --prefix libxml2)/lib CPPFLAGS=-I(brew --prefix libxml2)/include/libxml2 pip install --user lxml
#12
2
OSX 10.9.2
OSX 10.9.2
sudo env ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future STATIC_DEPS=true pip install lxml
#13
2
I tried all the answers on this page, none of them worked for me. I'm running OS X Version 10.9.2
我在这一页上试了所有的答案,没有一个对我有用。我正在运行OS X版本10.9.2。
But this definitely works....like a charm:
但这绝对....工作就像一个魅力:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install lxml
lxml ARCHFLAGS = -Wno-error = unused-command-line-argument-hard-error-in-future pip安装
#14
2
Unfortunately xcode-select --install
did not work for me as I already had the latest version.
不幸的是,xcode-select——安装对我来说并不适用,因为我已经有了最新版本。
It's very strange but I solved the issue by opening XCode and accepting the Terms & Conditions. Re-running pip install lxml
returned no errors after.
这很奇怪,但我通过打开XCode并接受条款和条件来解决这个问题。重新运行pip安装lxml后不会返回错误。
#15
0
I am using OSX 10.9.2 and I get the same error.
我使用osx10.9.2,得到相同的错误。
Installation of the XCode command line tools does not help for this particular version of OSX.
安装XCode命令行工具对这个特定版本的OSX没有帮助。
I think a better approach to fix this is to install with the following command:
我认为解决这个问题的更好方法是安装以下命令:
$ CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 pip install lxml
This is similar to jdkoftinoff' fix, but does not alter your system in a permanent way.
这类似于jdkoftinoff的修复,但不会永久地改变您的系统。
#16
0
I met the same question and after days of working I resolved this problem on my OS X 10.9.4, with Python 3.4.1.
我遇到了同样的问题,在工作了几天之后,我在OS X 10.9.4上解决了这个问题,使用了Python 3.4.1。
Here's my solution,
这是我的解决方案,
According to installing lxml from lxml.de,
根据lxml.de的安装lxml,
A macport of lxml is available. Try something like port install py25-lxml
有一个lxml的macport可用。试试端口安装py25-lxml。
If you do not have MacPort, install it from MacPort.org. It's quite easy. You may also need a compiler, to install XCode compiling tools, use xcode-select --install
如果您没有MacPort,请在MacPort.org上安装它。这很容易。您可能还需要一个编译器,来安装XCode编译工具,使用XCode -select—install。
Firstly I updated my port to the latest version via sudo port selfupdate
,
首先我通过sudo port selfupdate更新我的端口到最新版本,
Then I just type sudo port install libxml2
and several minutes later you should see libxml2 installed successfully. Probably you may also need libxslt
to install lxml. To install libxslt, use:sudo port install libxslt
.
然后我输入sudo端口安装libxml2,几分钟后您就会看到libxml2成功安装了。可能还需要libxslt来安装lxml。要安装libxslt,请使用:sudo端口安装libxslt。
Now, just type pip install lxml
, it should work fine.
现在,只需键入pip安装lxml,它就可以正常工作了。
#17
0
before compiling add the path that to xmlversion.h into your environment.
在编译之前,将该路径添加到xmlversion。h到您的环境。
$ set INCLUDE=$INCLUDE:/private/tmp/pip_build_root/lxml/src/lxml/
But make sure the path I've provided has the xmlversion.h file located inside. Then,
但是要确保我提供的路径有xmlversion。h文件里面。然后,
$ python setup.py install
#18
0
pip
did not work for me. I went to https://pypi.python.org/pypi/lxml/2.3 and downloaded the macosx .egg file:
匹普不适合我。我访问了https://pypi.python.org/pypi/lxml/2.3并下载了macosx .egg文件:
https://pypi.python.org/packages/2.7/l/lxml/lxml - 2.3 - 10.6 py2.7 - macosx intel.egg # md5 = 52322 e4698d68800c6b6aedb0dbe5f34
Then used command line easy_install
to install the .egg
file.
然后使用命令行easy_install安装.egg文件。
#19
0
This post links to a solution that worked for me Python3, lxml and "Symbol not found: _lzma_auto_decoder" on Mac OS X 10.9
这篇文章链接到一个为我工作的解决方案,它在Mac OS X 10.9上为我使用了Python3、lxml和“not found: _lzma_auto_decoder”。
hth
hth
#20
0
After successful install from pip (lxml 3.6.4) I was getting an error when importing the lxml.etree module.
在成功安装了pip (lxml 3.6.4)之后,我在导入lxml时遇到了一个错误。etree模块。
I was searching endlessly to install this as a requisite for scrapy, and tried all the options, but finally this worked for me (mac osx 10.11 python 2.7):
我一直在不停地搜索,想把它安装到剪贴板上,并尝试了所有的选项,但最终这对我起了作用(mac osx 10.11 python 2.7):
$ STATIC_DEPS=true sudo easy_install-2.7 "lxml==2.3.5"
The older version of lxml seem to work with etree module.
旧版本的lxml似乎与etree模块一起工作。
Pip can often ignore the specified version of a package, for example when you have the newer version in the pip cache, thus the easy_install
. The '-2.7'
option is for python version, omit this if you are installing for python 3.x.
Pip通常可以忽略包的指定版本,例如在Pip缓存中有较新的版本,因此easy_install。“-2.7”选项是python版本的,如果您正在安装python 3.x,请省略此选项。
#21
0
In my case, I must shutdown Kaspersky Antivirus before installing lxml by:
在我的例子中,我必须在安装lxml之前关闭卡巴斯基反病毒:
pip install lxml
#22
-1
Try:
试一试:
% STATIC_DEPS=true pip install lxml
Or:
或者:
% STATIC_DEPS=true sudo pip install lxml
It works!
它的工作原理!
#1
494
You should install or upgrade the commandline tool for xcode. Try this in a terminal:
您应该为xcode安装或升级命令行工具。在终端试试这个:
xcode-select --install
#2
186
I solved this issue on Yosemite by both installing and linking libxml2
and libxslt
through brew:
我在Yosemite上通过安装和链接libxml2和libxslt解决了这个问题:
brew install libxml2
brew install libxslt
brew link libxml2 --force
brew link libxslt --force
If you have solved the problem using this method but it pops up again at a later time, you might need to run this before the four lines above:
如果您已经使用此方法解决了问题,但稍后又会再次出现,您可能需要在上面的四行之前运行此方法:
brew unlink libxml2
brew unlink libxslt
If you are having permission errors with Homebrew, especially on El Capitan, this is a helpful document. In essence, regardless of OS X version, try running:
如果您在自制程序中有权限错误,特别是在El Capitan上,这是一个有用的文档。本质上,不管OS X版本,尝试运行:
sudo chown -R $(whoami):admin /usr/local
#3
97
You may solve your problem by running this on the commandline:
你可以通过命令行来解决你的问题:
STATIC_DEPS=true pip install lxml
It sure helped me. Explanations on docs
的确帮助了我。解释在文档
#4
47
I tried most of the solutions above, but none of them worked for me. I'm running Yosemite 10.10, the only solution that worked for me was to type this in the terminal:
我尝试了以上大部分的解决方案,但没有一个对我有效。我正在运行Yosemite 10.10,唯一的解决方案是在终端输入这个:
sudo CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install lxml
EDIT: If you are using virtualenv, the sudo in beginning is not needed.
编辑:如果您正在使用virtualenv,则不需要开始使用sudo。
#5
24
This has been bothering me as well for a while. I don't know the internals enough about python distutils etc, but the include path here is wrong. I made the following ugly hack to hold me over until the python lxml people can do the proper fix.
这也困扰了我一段时间。我不知道关于python distutils的内部细节,但是这里的include路径是错误的。在python lxml的人能做正确的修复之前,我做了下面这个丑陋的hack。
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2/libxml/ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml
#6
19
Installing globally... OS X 10.9.2
全球安装…OS X 10.9.2
xcode-select --install
sudo easy_install pip
sudo CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install lxml
#7
12
instalation instructions on http://lxml.de/installation.html explain:
http://lxml.de/installes.html的instalation说明:
To speed up the build in test environments, e.g. on a continuous integration server, disable the C compiler optimisations by setting the CFLAGS environment variable:
为了在测试环境中加速构建,例如在一个持续集成服务器上,通过设置CFLAGS环境变量来禁用C编译器优化:
CFLAGS="-O0" pip install lxml
#8
11
None of the above worked for me on 10.9.2, as compilation bails out with following error:
以上工作对我来说都不适用于10.9.2,因为编译时出现以下错误:
clang: error: unknown argument: '-mno-fused-madd'
Which actually lead to cleanest solution (see more details in [1]):
这实际上导致了最干净的解决方案(参见[1]):
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
pip install lxml
or following if installing globally
或者在全球安装。
sudo pip install lxml
[1] clang error: unknown argument: '-mno-fused-madd' (python package installation failure)
[1]clang错误:未知参数:'-mno- fusedmadd ' (python包安装失败)
#9
10
xcode-select --install
sudo easy_install pip
sudo pip install lxml
#10
5
I solved this issue on Yosemite
by running the following commands:
我通过运行以下命令解决了约塞米蒂的问题:
xcode-select install #this may take several minutes.
pip install lxml
#11
3
With homebrew, libxml2 is hidden to not interfere with the system libxml2, so pip must be helped a little in order to find it.
有了homebrew, libxml2就被隐藏起来,不会干扰到系统libxml2,因此必须稍微帮助pip才能找到它。
With bash:
bash:
LDFLAGS=-L`brew --prefix libxml2`/lib CPPFLAGS=-I`brew --prefix libxml2`/include/libxml2 pip install --user lxml
With fish:
与鱼:
env LDFLAGS=-L(brew --prefix libxml2)/lib CPPFLAGS=-I(brew --prefix libxml2)/include/libxml2 pip install --user lxml
#12
2
OSX 10.9.2
OSX 10.9.2
sudo env ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future STATIC_DEPS=true pip install lxml
#13
2
I tried all the answers on this page, none of them worked for me. I'm running OS X Version 10.9.2
我在这一页上试了所有的答案,没有一个对我有用。我正在运行OS X版本10.9.2。
But this definitely works....like a charm:
但这绝对....工作就像一个魅力:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install lxml
lxml ARCHFLAGS = -Wno-error = unused-command-line-argument-hard-error-in-future pip安装
#14
2
Unfortunately xcode-select --install
did not work for me as I already had the latest version.
不幸的是,xcode-select——安装对我来说并不适用,因为我已经有了最新版本。
It's very strange but I solved the issue by opening XCode and accepting the Terms & Conditions. Re-running pip install lxml
returned no errors after.
这很奇怪,但我通过打开XCode并接受条款和条件来解决这个问题。重新运行pip安装lxml后不会返回错误。
#15
0
I am using OSX 10.9.2 and I get the same error.
我使用osx10.9.2,得到相同的错误。
Installation of the XCode command line tools does not help for this particular version of OSX.
安装XCode命令行工具对这个特定版本的OSX没有帮助。
I think a better approach to fix this is to install with the following command:
我认为解决这个问题的更好方法是安装以下命令:
$ CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 pip install lxml
This is similar to jdkoftinoff' fix, but does not alter your system in a permanent way.
这类似于jdkoftinoff的修复,但不会永久地改变您的系统。
#16
0
I met the same question and after days of working I resolved this problem on my OS X 10.9.4, with Python 3.4.1.
我遇到了同样的问题,在工作了几天之后,我在OS X 10.9.4上解决了这个问题,使用了Python 3.4.1。
Here's my solution,
这是我的解决方案,
According to installing lxml from lxml.de,
根据lxml.de的安装lxml,
A macport of lxml is available. Try something like port install py25-lxml
有一个lxml的macport可用。试试端口安装py25-lxml。
If you do not have MacPort, install it from MacPort.org. It's quite easy. You may also need a compiler, to install XCode compiling tools, use xcode-select --install
如果您没有MacPort,请在MacPort.org上安装它。这很容易。您可能还需要一个编译器,来安装XCode编译工具,使用XCode -select—install。
Firstly I updated my port to the latest version via sudo port selfupdate
,
首先我通过sudo port selfupdate更新我的端口到最新版本,
Then I just type sudo port install libxml2
and several minutes later you should see libxml2 installed successfully. Probably you may also need libxslt
to install lxml. To install libxslt, use:sudo port install libxslt
.
然后我输入sudo端口安装libxml2,几分钟后您就会看到libxml2成功安装了。可能还需要libxslt来安装lxml。要安装libxslt,请使用:sudo端口安装libxslt。
Now, just type pip install lxml
, it should work fine.
现在,只需键入pip安装lxml,它就可以正常工作了。
#17
0
before compiling add the path that to xmlversion.h into your environment.
在编译之前,将该路径添加到xmlversion。h到您的环境。
$ set INCLUDE=$INCLUDE:/private/tmp/pip_build_root/lxml/src/lxml/
But make sure the path I've provided has the xmlversion.h file located inside. Then,
但是要确保我提供的路径有xmlversion。h文件里面。然后,
$ python setup.py install
#18
0
pip
did not work for me. I went to https://pypi.python.org/pypi/lxml/2.3 and downloaded the macosx .egg file:
匹普不适合我。我访问了https://pypi.python.org/pypi/lxml/2.3并下载了macosx .egg文件:
https://pypi.python.org/packages/2.7/l/lxml/lxml - 2.3 - 10.6 py2.7 - macosx intel.egg # md5 = 52322 e4698d68800c6b6aedb0dbe5f34
Then used command line easy_install
to install the .egg
file.
然后使用命令行easy_install安装.egg文件。
#19
0
This post links to a solution that worked for me Python3, lxml and "Symbol not found: _lzma_auto_decoder" on Mac OS X 10.9
这篇文章链接到一个为我工作的解决方案,它在Mac OS X 10.9上为我使用了Python3、lxml和“not found: _lzma_auto_decoder”。
hth
hth
#20
0
After successful install from pip (lxml 3.6.4) I was getting an error when importing the lxml.etree module.
在成功安装了pip (lxml 3.6.4)之后,我在导入lxml时遇到了一个错误。etree模块。
I was searching endlessly to install this as a requisite for scrapy, and tried all the options, but finally this worked for me (mac osx 10.11 python 2.7):
我一直在不停地搜索,想把它安装到剪贴板上,并尝试了所有的选项,但最终这对我起了作用(mac osx 10.11 python 2.7):
$ STATIC_DEPS=true sudo easy_install-2.7 "lxml==2.3.5"
The older version of lxml seem to work with etree module.
旧版本的lxml似乎与etree模块一起工作。
Pip can often ignore the specified version of a package, for example when you have the newer version in the pip cache, thus the easy_install
. The '-2.7'
option is for python version, omit this if you are installing for python 3.x.
Pip通常可以忽略包的指定版本,例如在Pip缓存中有较新的版本,因此easy_install。“-2.7”选项是python版本的,如果您正在安装python 3.x,请省略此选项。
#21
0
In my case, I must shutdown Kaspersky Antivirus before installing lxml by:
在我的例子中,我必须在安装lxml之前关闭卡巴斯基反病毒:
pip install lxml
#22
-1
Try:
试一试:
% STATIC_DEPS=true pip install lxml
Or:
或者:
% STATIC_DEPS=true sudo pip install lxml
It works!
它的工作原理!