我正在尝试从 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
ImportError Traceback (most recent call last) in () 1 import pandas as pd ----> 2 f_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
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 found, please install it") ImportError: html5lib not found, please install it
我也安装了 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')
关于python - Pandas :read_html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34555135/