I am using python 2.7.5 on mac 10.7.5, beautifulsoup 4.2.1. I am going to parse an XML page using the lxml library as described in the beautifulsoup tutorial. However, when I run my code, it shows
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml,xml. Do you need to install a parser library?
I am sure that I have already installed lxml in all ways: easy_install, pip, port, etc. I tried adding a line to my code to see if lxml is installed or not:
import lxml
Then python can simply successfully pass this code and display the previous error message again, occurring on the same line.
So, I am sure that lxml has been installed but not installed correctly. So I decided to uninstall lxml and then reinstall using the βcorrectβ method. But when I type
easy_install -m lxml
He shows:
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, in order to select the desired version: pkg_resources.require("lxml")
So, I do not know how to continue uninstalling ...
I looked through a lot of posts about this issue on Google, but still can not find any useful information.
Here is my code:
import mechanize from bs4 import BeautifulSoup import lxml class count: def __init__(self,protein): self.proteinCode = protein self.br = mechanize.Browser() def first_search(self):
I want to know:
- How to remove lxml?
- How to install lxml "correctly"? How to know that it is installed correctly?
python easy-install lxml beautifulsoup
Mark23333 Jul 20 '13 at 21:11 2013-07-20 21:11
source share