有人能解释一下我为什么会出现这个错误吗[重要提示:找不到lxml,请安装它]

2024-10-03 06:22:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用pandas库中的.read_html()函数,并在shell中运行代码时一直遇到此错误。我看到你需要安装lxml,所以我用apt-get来安装。但后来当我试图再次运行它时,我得到了同样的错误。在

(trusty)mdz5032@localhost:~$ sudo apt-get -y install python-lxml
[sudo] password for mdz5032: 
Reading package lists... Done
.
.
.
python-lxml is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

这是我正在使用的代码

^{pr2}$

我拿出了api密钥,但如果需要的话可以发布它。在

这是完整的回溯

Traceback (most recent call last):
  File "/home/mdz5032/pandasPractice.py", line 9, in <module>
    fiddy_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
  File "/usr/local/lib/python3.4/dist-packages/pandas/io/html.py", line 874, in read_html
    parse_dates, tupleize_cols, thousands, attrs, encoding)
  File "/usr/local/lib/python3.4/dist-packages/pandas/io/html.py", line 726, in _parse
    parser = _parser_dispatch(flav)
  File "/usr/local/lib/python3.4/dist-packages/pandas/io/html.py", line 685, in _parser_dispatch
    raise ImportError("lxml not found, please install it")
ImportError: lxml not found, please install it

Tags: installinpypandasreadlibusrlocal