无法在MacOS 10.8.4中安装lxml

2024-05-29 08:16:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我在将lxml安装到Mac操作系统时遇到问题。 我在建造它时有以下错误。这是我在使用pip install lxml时出现的错误

/private/var/folders/9s/s5hl5w4x7zjdjkdljw9cnsrm0000gn/T/pip-build-khuevu/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found

我已将libxml2与brew一起安装:

brew install libxml2
brew link libxml2 --force

我刚认识麦克。在Ubuntu中,这意味着必须安装libxml2 dev包。

更新:这里是pip.log:

"~/.pip/pip.log" 124L, 8293C requirement_set.install(install_options, global_options, root=options.root_path) File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 1185, in install requirement.install(install_options, global_options, *args, **kwargs) File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 592, in install cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False) File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/util.py", line 662, in call_subprocess % (command_desc, proc.returncode, cwd)) InstallationError: Command /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;file='/private/var/folders/9s/s5hl5w4x7zjdjkdljw9cnsrm0000gn/T/pip-build-khuevu/lxml/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/9s/s5hl5w4x7zjdjkdljw9cnsrm0000gn/T/pip-nsV0iT-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/var/folders/9s/s5hl5w4x7zjdjkdljw9cnsrm0000gn/T/pip-build-khuevu/lxml

知道吗? 非常感谢


Tags: installpipvarusrlocalframeworkversionslxml
3条回答

其他答案(导出C_INCLUDE_PATH)对我都不起作用。但是,将CFLAGS环境变量设置为内置的OS X 10.10libxml2根文件非常有用。

export CFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2

结果是xmlversion.h不包含在编译路径中,即使它在路径中。修改C_INCLUDE_PATH env为我修复错误:

C_INCLUDE_PATH=/usr/local/Cellar/libxml2/2.9.1/include/libxml2:$C_INCLUDE_PATH

如果运行的是安装了Xcode的Mavericks,还可以使用:

export C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/libxml2:$C_INCLUDE_PATH

相关问题 更多 >

    热门问题