【发布时间】:2022-08-19 05:29:02
【问题描述】:
我在 VS Code 中使用带有 python 版本 3.9.9 的虚拟环境,即使在我 pip install lxml 之后仍然收到相同的错误。我能够在 jupyter notebook 中使用 python 3.8.8 成功地做到这一点,但无法弄清楚如何在这个新环境中做到这一点。 这是我的代码:
import pandas as pd
url = \'https://en.wikipedia.org/wiki/Young_Thug\'
df = pd.read_html(url)[0]
这是我的错误:
>>> import pandas as pd
>>> ml_url = \'https://en.wikipedia.org/wiki/Young_Thug\'
>>> ml_df_original = pd.read_html(ml_url)
Traceback (most recent call last):
File \"<stdin>\", line 1, in <module>
File \"C:\\Users\\main\\pyenvs\\py39ve\\lib\\site-packages\\pandas\\util\\_decorators.py\", line 311, in wrapper
return func(*args, **kwargs)
File \"C:\\Users\\main\\pyenvs\\py39ve\\lib\\site-packages\\pandas\\io\\html.py\", line 1113, in read_html
return _parse(
File \"C:\\Users\\main\\pyenvs\\py39ve\\lib\\site-packages\\pandas\\io\\html.py\", line 915, in _parse
parser = _parser_dispatch(flav)
File \"C:\\Users\\main\\pyenvs\\py39ve\\lib\\site-packages\\pandas\\io\\html.py\", line 872, in _parser_dispatch
raise ImportError(\"lxml not found, please install it\")
ImportError: lxml not found, please install it
我尝试了this 页面上的所有建议,但没有任何效果。感谢任何能提供帮助的人。
标签: python pandas visual-studio