python - 在 Fedora 上运行 python 脚本时没有名为 lxml.html 的模块

标签 python linux lxml fedora

我正在尝试在 Fedora 服务器上运行 python 脚本。我收到以下错误。

/usr/bin/python report_generation.py
Traceback (most recent call last):
File "report_generation.py", line 9, in ?
import lxml.html
ImportError: No module named lxml.html

做一些研究,我发现它需要 python-lxml 包来运行脚本。这台机器已经安装了一些 lxml。但是,我无法完成这项工作。

yum search libxml

libxml2.i386 : Library providing XML and HTML support
libxml2.x86_64 : Library providing XML and HTML support
libxml2-devel.i386 : Libraries, includes, etc. to develop XML and HTML applications
libxml2-devel.x86_64 : Libraries, includes, etc. to develop XML and HTML applications
libxml2-python.x86_64 : Python bindings for the libxml2 library
libxslt.i386 : Library providing the Gnome XSLT engine
libxslt.x86_64 : Library providing the Gnome XSLT engine
libxslt-devel.i386 : Libraries, includes, etc. to embed the Gnome XSLT engine
libxslt-devel.x86_64 : Libraries, includes, etc. to embed the Gnome XSLT engine
libxslt-python.x86_64 : Python bindings for the libxslt library

此外,当我尝试安装这些软件包时,它说所有这些都是最新的。出于某种原因,它没有选择 lxml 模块并在运行脚本时抛出此错误。 我是 Linux 和 Python 的新手。请提供任何线索来调试此问题。

最佳答案

sudo yum install python-lxml 

sudo apt-get install python-lxml

关于python - 在 Fedora 上运行 python 脚本时没有名为 lxml.html 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21004960/

相关文章:

python - 在另一棵树下插入一棵树(lxml)

python - 使用lxml解析html文档时出现编码问题

python - 使用 openCV 识别 HSV 中的颜色范围

python - 如何使用 Pandas 重新排列索引级别?

linux - 内核模块中的 obj-m 变量

linux - 我如何告诉 bash 脚本从头开始?

python - 一次读取和打印一个字符 - Python 中的 getche() 和退格键

python - Python 2.7 中的类型转换

linux - 捕获 ssl,对其进行解码,并保存原始输出

python - 我可以在 Python 3 上提供 lxml.etree.parse 的 URL 吗?