当前位置:  开发笔记 > 编程语言 > 正文

熊猫:read_html

如何解决《熊猫:read_html》经验,为你挑选了1个好方法。

我正在尝试从维基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,但它无法正常工作.有人可以帮忙吗?



1> Tim Seed..:

在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') 


谢谢,这很有效.虽然我已经安装了所有这些,但我重新安装了它,并打开了一个新实例,并且它工作正常.谢谢
推荐阅读
mobiledu2402852357
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有