Dav*_*gan 233 python macos xcode lxml scrapy
我想安装Lxml,然后我可以安装Scrapy.
当我今天更新我的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
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用brew来安装libxml2和libxslt,两者都安装得很好但我仍然无法安装lxml.
上次我安装时我需要在Xcode上启用开发人员工具,但由于它更新到Xcode 5,它不再给我这个选项了.
有谁知道我需要做什么?
小智 499
您应该安装或升级xcode的命令行工具.在终端试试这个:
xcode-select --install
Run Code Online (Sandbox Code Playgroud)
Mar*_*son 193
我通过安装和链接libxml2以及libxsltbrew 解决了Yosemite上的这个问题:
brew install libxml2
brew install libxslt
brew link libxml2 --force
brew link libxslt --force
Run Code Online (Sandbox Code Playgroud)
如果您使用此方法解决了问题但稍后再次弹出,则可能需要在上面的四行之前运行此方法:
brew unlink libxml2
brew unlink libxslt
Run Code Online (Sandbox Code Playgroud)
如果您在使用Homebrew时遇到权限错误,特别是在El Capitan上,这是一个有用的文档.从本质上讲,无论OS X版本如何,请尝试运行:
sudo chown -R $(whoami):admin /usr/local
Run Code Online (Sandbox Code Playgroud)
And*_*sto 101
您可以通过在命令行上运行它来解决您的问题:
STATIC_DEPS=true pip install lxml
Run Code Online (Sandbox Code Playgroud)
它确实帮助了我.关于文档的解释
rob*_*nsj 48
我尝试了上面的大多数解决方案,但它们都没有为我工作.我正在运行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
Run Code Online (Sandbox Code Playgroud)
编辑:如果你使用virtualenv,不需要开头的sudo.
jdk*_*off 24
这一直困扰着我.我不知道内部有关python distutils等的内容,但这里的include路径是错误的.我做了以下丑陋的黑客来阻止我,直到python lxml人们可以做正确的修复.
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
Run Code Online (Sandbox Code Playgroud)
Sam*_*lar 19
全局安装... 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
Run Code Online (Sandbox Code Playgroud)
pan*_*ore 12
http://lxml.de/installation.html上的安装说明解释:
要加速测试环境中的构建,例如在持续集成服务器上,请通过设置CFLAGS环境变量来禁用C编译器优化:
CFLAGS="-O0" pip install lxml
Run Code Online (Sandbox Code Playgroud)
oki*_*gan 11
以上都不适用于10.9.2,因为编译出现以下错误:
clang: error: unknown argument: '-mno-fused-madd'
Run Code Online (Sandbox Code Playgroud)
这实际上导致了最干净的解决方案(参见[1]中的更多细节):
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
pip install lxml
Run Code Online (Sandbox Code Playgroud)
如果全球安装,则遵循
sudo pip install lxml
Run Code Online (Sandbox Code Playgroud)
[1] clang错误:未知参数:'-mno-fused-madd'(python包安装失败)
小智 10
xcode-select --install
sudo easy_install pip
sudo pip install lxml
Run Code Online (Sandbox Code Playgroud)
我Yosemite通过运行以下命令解决了这个问题:
xcode-select install #this may take several minutes.
pip install lxml
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88806 次 |
| 最近记录: |