我正在尝试从维基URL中提取美国各州,而我正在使用Python Pandas.
import pandas as pd import html5lib f_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
但是,上面的代码给了我一个错误L.
(1)导入pandas中的ImportError Traceback(最近调用最后一次)为pd ----> 2 f_states = pd.read_html(' https://simple.wikipedia.org/wiki/List_of_U.S._states ')
如果味道在'''bs4','html5lib'):662如果不是_HAS_HTML5LIB: - > 663引发ImportError("找不到html5lib,请安装它")664如果不是_HAS_BS4:665引发ImportError("BeautifulSoup4(bs4)not not发现,请安装它")ImportError:找不到html5lib,请安装它
我也安装了html5lib和beautifulsoup4,但它无法正常工作.有人可以帮忙吗?
在mac上运行Python 3.4
新的pyvenv
pip install pandas pip install lxml pip install html5lib pip install BeautifulSoup4
然后运行你的例子它应该工作:
import pandas as pd import html5lib f_states= pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')