"导入错误:找不到 lxml,请安装它"使用 VS Code 安装 lxml 后



我在VS Code中使用的是一个带有python 3.9.9版本的虚拟环境,即使在我pip-install lxml之后,仍然会出现同样的错误。我能够使用python 3.8.8在jupyter笔记本电脑上成功地做到这一点,但我不知道如何在这个新环境中做到。这是我的代码:

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:Usersmainpyenvspy39velibsite-packagespandasutil_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "C:Usersmainpyenvspy39velibsite-packagespandasiohtml.py", line 1113, in read_html
return _parse(
File "C:Usersmainpyenvspy39velibsite-packagespandasiohtml.py", line 915, in _parse
parser = _parser_dispatch(flav)
File "C:Usersmainpyenvspy39velibsite-packagespandasiohtml.py", line 872, in _parser_dispatch
raise ImportError("lxml not found, please install it")
ImportError: lxml not found, please install it

我尝试了这个页面上的所有建议,但都没有成功。感谢任何能提供帮助的人。

正如我们在这个博客中看到的,错过了安装lxml包,请尝试:

pip install lxml

最新更新