我正在尝试从 wiki 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 import pandas as pd —-> 2 f_states = pd.read_html(’ https://simple.wikipedia.org/wiki/List_of_U.S._states ‘) 中的 ImportError Traceback (most recent call last)
if flavor in (‘bs4’, ‘html5lib’): 662 if not _HAS_HTML5LIB: –> 663 raise ImportError(“html5lib not found, please install it”) 664 if not _HAS_BS4: 665 raise ImportError(“BeautifulSoup4 (bs4) not找到,请安装”) ImportError: html5lib not found,请安装
我也安装了 html5lib 和 beautifulsoup4,但它不工作。有人可以帮忙吗?
原文由 user4943236 发布,翻译遵循 CC BY-SA 4.0 许可协议
在 Mac 上运行 Python 3.4
新的pyvenv
然后运行您的示例,它应该可以工作: