在运行 python 脚本时,我得到了这个错误
from lxml import etree
ImportError: No module named lxml
现在我尝试安装 lxml
sudo easy_install lmxl
但它给了我以下错误
Building lxml version 2.3.beta1.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' needs to be available.
ERROR: /bin/sh: xslt-config: not found
** make sure the development packages of libxml2 and libxslt are installed **
使用 libxslt 的构建配置
src/lxml/lxml.etree.c:4: fatal error: Python.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
最佳答案
只要做:
sudo apt-get install python-lxml
对于 Python 2(例如,Inkscape 需要):
sudo apt-get install python2-lxml
如果您打算从源代码安装,那么 albertov's answer会有所帮助。但除非有原因,否则不要,直接从存储库安装它。
关于python - 在 python 中安装 lxml 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4598229/