|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我的代码如下:
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[1]
报错:
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[1]
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[flavor]
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库。
请大家帮我看看这个问题应该怎么解决!!!
|
-
这是我的代码和报错
|