我有一个为Python 2.5创建的virtualenv,并希望将其"升级"为Python 2.6.
以下是最初的设置方式:
virtualenv --no-site-packages -p python2.5 myenv
Run Code Online (Sandbox Code Playgroud)
我现在在同一目录中运行virtualenv进行升级:
virtualenv --no-site-packages -p python2.6 myenv
...
Not overwriting existing python script myenv/bin/python (you must use myenv/bin/python2.6)
...
Overwriting myenv/bin/activate with new content
Run Code Online (Sandbox Code Playgroud)
默认的python仍然是2.5,即使我也可以指定2.6.有没有办法完全删除 2.5并将'bin/python'指向2.6而不是?
我在mac 10.7.5上使用python 2,7.5,beautifulsoup 4.2.1.我将使用lxml库解析xml页面,如beautifulsoup教程中所述.但是,当我运行我的代码时,它会显示出来
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
lxml,xml. Do you need to install a parser library?
Run Code Online (Sandbox Code Playgroud)
我确信我已经通过所有方法安装了lxml:easy_install,pip,port等.我试着在我的代码中添加一行,看看是否安装了lxml:
import lxml
Run Code Online (Sandbox Code Playgroud)
然后python可以成功浏览此代码并再次显示上一条错误消息,发生在同一行.
所以我很确定已经安装了lxml,但没有正确安装.所以我决定卸载lxml,然后使用'正确'方法重新安装.但是当我输入时
easy_install -m lxml
Run Code Online (Sandbox Code Playgroud)
表明:
Searching for lxml
Best match: lxml 3.2.1
Processing lxml-3.2.1-py2.7-macosx-10.6-intel.egg
Using /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-
3.2.1-py2.7-macosx-10.6-intel.egg
Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Beautiful Soup 来解析 XML 文档。这是我实例化对象的代码BeautifulSoup:
with open(filename, encoding='utf-8') as f_:
content = f_.read()
xml_cont = BeautifulSoup(content, 'lxml')
Run Code Online (Sandbox Code Playgroud)
当我运行我的代码时,我收到以下错误:
File "[omitted]", line 13, in [omitted]
xml_cont = BeautifulSoup(content, 'lxml')
File "/Users/Josh/Library/Python/3.7/lib/python/site-packages/bs4/__init__.py", line 228, 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)
我快速搜索了一下,发现我需要lxml用 pip 安装。我就这么做了。
pip3 install lxml
Run Code Online (Sandbox Code Playgroud)
但是,我仍然收到错误!有什么想法吗?
我正在尝试使用 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 来抓取数据。
我尝试将suppy4与我的python3.5配合使用,但是每当我统治一个代码以从Internet提取某些东西时,我都会收到此错误:
- s4\__init__.py", line 198, in __init__
% ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?
Run Code Online (Sandbox Code Playgroud)
该站点bs4.FeatureNotFound中存在一个具有相同错误的链接:找不到具有您请求的功能的树生成器:lxml。您需要安装解析器库吗? 我尝试了所有,仍然得到错误
所有的pip安装请求pip install lxml pip install beautifull soup4
我下载了汤4 https://www.crummy.com/software/BeautifulSoup/bs4/download/4.6/手动安装setup.py install
我已经更新并可以正常工作了,但是仍然出现错误,请帮助我