Python报错找不到lxml,ImportError: lxml not found, please install it
我的代码如下:import pandas as pd
import requests
html_data = requests.get('http://kaoshi.edu.sina.com.cn/college/majorlist/')
html_table_data = pd.read_html(html_data.content, encoding = 'utf-8')
html_table_data
报错:
ImportError Traceback (most recent call last)
<ipython-input-84-65cfd60fdede> in <module>
2 import requests
3 html_data = requests.get('http://kaoshi.edu.sina.com.cn/college/majorlist/')
----> 4 html_table_data = pd.read_html(html_data.content, encoding = 'utf-8')
5 html_table_data
d:\python\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
297 )
298 warnings.warn(msg, FutureWarning, stacklevel=stacklevel)
--> 299 return func(*args, **kwargs)
300
301 return wrapper
d:\python\lib\site-packages\pandas\io\html.py in read_html(io, match, flavor, header, index_col, skiprows, attrs, parse_dates, thousands, encoding, decimal, converters, na_values, keep_default_na, displayed_only)
1083 io = stringify_path(io)
1084
-> 1085 return _parse(
1086 flavor=flavor,
1087 io=io,
d:\python\lib\site-packages\pandas\io\html.py in _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs)
887 retained = None
888 for flav in flavor:
--> 889 parser = _parser_dispatch(flav)
890 p = parser(io, compiled_match, attrs, encoding, displayed_only)
891
d:\python\lib\site-packages\pandas\io\html.py in _parser_dispatch(flavor)
844 else:
845 if not _HAS_LXML:
--> 846 raise ImportError("lxml not found, please install it")
847 return _valid_parsers
848
ImportError: lxml not found, please install it
我使用代码:pip3 install lxml
Requirement already satisfied: lxml in d:\python\lib\site-packages (4.6.3)
这显示的我的lxml库已经安装好了的,但是我重新执行我的代码后,还是报错找不到lxml库。
请大家帮我看看这个问题应该怎么解决!!!
电脑上装几个python呢 wp231957 发表于 2021-6-29 18:24
电脑上装几个python呢
我就安装了一个Python wp231957 发表于 2021-6-29 18:24
电脑上装几个python呢
我一般是用的jupyter notebook,刚刚在我重新启动jupyter notebook后,又执行居然成功了,不太懂。。。 本帖最后由 wsw530 于 2021-6-29 19:07 编辑
requests 库需要依赖 lxml库只需要安装一下lxml库就可以了
我的是python3.8的,包管理器使用pip3
pip3 install lxml
就可以了
我这里试着是可以的,你也可以试试卸载重装一次,在执行看看 wsw530 发表于 2021-6-29 18:58
requests 库需要依赖 lxml库只需要安装一下lxml库就可以了
我的是python3.8的,包管理器使用pip3
pip3 in ...
谢谢
页:
[1]