本文介绍了 pandas :read_html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Wiki URL中提取美国各州,为此我正在使用Python Pandas.

I'm trying to extract US states from wiki URL, and for which I'm using Python Pandas.

import pandas as pd
import html5lib
f_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states') 

但是,上面的代码给我一个错误L

However, the above code is giving me an error L

如果在('bs4','html5lib')中具有风味: 662(如果不是)_HAS_HTML5LIB: -> 663引发ImportError(找不到html5lib,请安装它") 664(如果不是_HAS_BS4): 665提高ImportError(找不到BeautifulSoup4(bs4),请安装它") ImportError:找不到html5lib,请安装

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,但无法正常工作.有人可以帮忙吗?

I installed html5lib and beautifulsoup4 as well, but it is not working. Can someone help pls.

推荐答案

在Mac上运行Python 3.4

Running Python 3.4 on a mac

新的pyvenv

pip install pandas
pip install lxml
pip install html5lib
pip install BeautifulSoup4

然后运行您的示例,它应该可以工作:

Then run your example and it should work:

import pandas as pd
import html5lib
f_states=   pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states') 

这篇关于 pandas :read_html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 14:31