Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Better error if BeautifulSoup import fails

  • Loading branch information...
commit 70ad3f15c40e161e38a505317ad83b44b548bdea 1 parent d3559d1
@batterseapower batterseapower authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 pinyin/
9 pinyin/
@@ -3,7 +3,6 @@
import htmlentitydefs
import re
-from BeautifulSoup import BeautifulSoup, Tag
import sqlalchemy
import unicodedata
@@ -332,6 +331,14 @@ def tokenizetext(text, forcenumeric):
def tokenize(html, forcenumeric=False):
+ try:
+ from BeautifulSoup import BeautifulSoup, Tag
+ except ImportError, e:
+ if utils.islinux():
+ raise ImportError("Could not import the Beautiful Soup library! Since you are running on Linux, you may have to install it manually. Try running 'sudo apt-get install python-beautifulsoup' using the terminal.")
+ else:
+ raise e
def extract_attr_maybe(attrs, attr, into, extractor):
if attr not in attrs:
return {}
Please sign in to comment.
Something went wrong with that request. Please try again.