summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bs4/diagnose.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/bs4/diagnose.py b/bs4/diagnose.py
index 4d0b00a..1b71983 100644
--- a/bs4/diagnose.py
+++ b/bs4/diagnose.py
@@ -33,12 +33,21 @@ def diagnose(data):
if 'lxml' in basic_parsers:
basic_parsers.append(["lxml", "xml"])
- from lxml import etree
- print "Found lxml version %s" % ".".join(map(str,etree.LXML_VERSION))
+ try:
+ from lxml import etree
+ print "Found lxml version %s" % ".".join(map(str,etree.LXML_VERSION))
+ except ImportError, e:
+ print (
+ "lxml is not installed or couldn't be imported.")
+
if 'html5lib' in basic_parsers:
- import html5lib
- print "Found html5lib version %s" % html5lib.__version__
+ try:
+ import html5lib
+ print "Found html5lib version %s" % html5lib.__version__
+ except ImportError, e:
+ print (
+ "html5lib is not installed or couldn't be imported.")
if hasattr(data, 'read'):
data = data.read()