You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

PyCharm社区版pd.read_html无法识别已安装的lxml问题

问题:已安装lxml但pandas.read_html仍提示“lxml not found”?

我在PyCharm社区版里尝试用pandas读取FDIC的失败银行列表页面,代码如下:

data = pd.read_html('https://www.fdic.gov/bank/individual/failed/banklist.html')

明明已经安装了lxml库,而且能在虚拟环境的site-packages目录里找到它,但运行时还是抛出了ImportError:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\cc15522\OneDrive - University of Bristol\Documents\Python\venv\lib\site-packages\pandas\io\html.py", line 1094, in read_html
    displayed_only=displayed_only)
  File "C:\Users\cc15522\OneDrive - University of Bristol\Documents\Python\venv\lib\site-packages\pandas\io\html.py", line 894, in _parse
    parser = _parser_dispatch(flav)
  File "C:\Users\cc15522\OneDrive - University of Bristol\Documents\Python\venv\lib\site-packages\pandas\io\html.py", line 851, in _parser_dispatch
    raise ImportError("lxml not found, please install it")
ImportError: lxml not found, please install it

我是在学校的电脑上操作的,有没有小伙伴遇到过类似的问题?


解决方法

后来我试着重启了一下电脑,系统居然就成功识别到lxml包了!真的是大意了,早知道应该先重启再发帖的,哈哈😂

内容的提问来源于stack exchange,提问作者user9903833

火山引擎 最新活动