我想安装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,它不再给我这个选项了.
有谁知道我需要做什么?
...
soup = BeautifulSoup(html, "lxml")
File "/Library/Python/2.7/site-packages/bs4/__init__.py", line 152, in __init__
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
Run Code Online (Sandbox Code Playgroud)
以上输出在我的终端上.我在Mac OS 10.7.x上.我有Python 2.7.1,并按照本教程获得Beautiful Soup和lxml,它们都已成功安装并使用位于此处的单独测试文件.在导致此错误的Python脚本中,我包含了这一行:
from pageCrawler import comparePages
在pageCrawler文件中,我包含以下两行:
from bs4 import BeautifulSoup
from urllib2 import urlopen
任何有关确定问题是什么以及如何解决问题的帮助都将不胜感激.
我已经尝试了这一点并且在过去多次遇到问题.有没有人在没有MacPorts或Fink的OS X上安装lxml的配方肯定有用?
优选地,具有用于下载和构建每个依赖性的完整1-2-3步骤.
我正在尝试使用 beautifulsoup4 来解析一系列用 XHTML 编写的网页。我假设为了获得最佳结果,我应该与 xml 解析器配对,据我所知,beautifulsoup 支持的唯一解析器是 lxml。
但是,当我尝试按照 beautifuloup 文档运行以下命令时:
import requests
from bs4 import BeautifulSoup
r = requests.get(‘hereiswhereiputmyurl’)
soup = BeautifulSoup(r.content, ‘xml’)
Run Code Online (Sandbox Code Playgroud)
它导致以下错误:
FeatureNotFound: Couldn't find a tree builder with the features you
requested: xml. Do you need to install a parser library?
Run Code Online (Sandbox Code Playgroud)
这让我疯狂。我找到了其他两个发布相同问题的用户的记录
在这里 bs4.FeatureNotFound:找不到具有您请求的功能的树构建器:lxml。你需要安装解析器库吗?
我使用这篇文章(请参阅此行正下方的链接)重新安装和更新 lxml 并更新了漂亮的汤,但我仍然收到错误消息。 在 Windows 8.1 上安装 lxml、libxml2、libxslt
Beautifulsoup 正在工作,因为我运行了以下代码,它向我展示了它通常的标记语言墙汤 = BeautifulSoup(r.content, 'html.parser')
这是我的规格 Windows 8.1 Python 3.5.2 我使用 Anaconda 3 中的 spyder ide 来运行我的代码(诚然,我不太了解)
我确信初学者会这样做,因为正如我之前所说,我几乎没有编程经验。
我该如何解决这个问题,或者如果它是一个已知的错误,你们会建议我单独使用 lxml 来抓取数据。
我已从我的Mac(10.7.5)中删除了MacPorts,现在Python似乎已被破坏.我正在尝试运行scrapy,最后得到以下错误:
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml-2.3.4-py2.7-macosx-10.7-intel.egg/lxml/etree.so, 2): Symbol not found: _exsltDateXpathCtxtRegister
Referenced from: /Library/Python/2.7/site-packages/lxml-2.3.4-py2.7-macosx-10.7-intel.egg/lxml/etree.so
Expected in: /usr/lib/libexslt.0.dylib
in /Library/Python/2.7/site-packages/lxml-2.3.4-py2.7-macosx-10.7-intel.egg/lxml/etree.so
Run Code Online (Sandbox Code Playgroud)
当我运行python并尝试导入该库时,我得到如下错误:
$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 14:13:39)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml-2.3.4-py2.7-macosx-10.7-intel.egg/lxml/etree.so, 2): Symbol not found: _xsltDocDefaultLoader
Referenced from: /Library/Python/2.7/site-packages/lxml-2.3.4-py2.7-macosx-10.7-intel.egg/lxml/etree.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/lxml-2.3.4-py2.7-macosx-10.7-intel.egg/lxml/etree.so
Run Code Online (Sandbox Code Playgroud)
我现在该如何清理这个烂摊子?
lxml ×4
python ×4
macos ×2
anaconda ×1
osx-leopard ×1
python-2.7 ×1
python-3.x ×1
scrapy ×1
shell ×1
xcode ×1