CentOS 6.3 上的 Python lxml etree

标签 python centos lxml centos6

我的服务器上有 Centos 6,我一直在尝试为它安装一些包(模块)。我只是将我 Windows 上的那些带到 /usr/lib/python2.6/site-packages 中的 ftp 客户端,但是当我运行我的脚本时,其中一个 - lxml 给我一个错误:

File "plugins/util/http.py", line 12, in <module>
    from lxml import etree, html
  File "/usr/lib/python2.6/site-packages/lxml/html/__init__.py", line 12, in <module>
ImportError: cannot import name etree

相同的代码在 Windows 7 和 Linux Ubuntu 10.04 上完美运行。

有谁知道为什么会返回这个错误?我没有修改任何东西,只是将模块从 windows 移动到我 vps 上的 python2.6 目录。

@根:

>>> import lxml;print lxml
<module 'lxml' from '/usr/lib/python2.6/site-packages/lxml/__init__.pyc'>
>>>

@ig

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -I/tmp/pip-build/lxml/src/lxml/includes -I/usr/include/python2.6 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.6/src/lxml/lxml.etree.o

无法执行 gcc:没有那个文件或目录

错误:命令 'gcc' 失败,退出状态为 1

最佳答案

或者从 EPEL 安装它(最简单的方法):

# install EPEL if you don't have it yet
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# instal python-lxml
sudo yum -y install python-lxml

关于CentOS 6.3 上的 Python lxml etree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14518769/

相关文章:

python - 将文本 append 到文件。将文本添加到指定的 txt 文件。

Python 类看不到方法,除非我注释掉 __init__

python - 获取 shell 输入作为字符串,而不是列表

json - CGI 脚本向我显示 "garbage"而不是 JSON 对象

python-3.x - 输入 lxml 的提示?

python - 假设 Sympy 中复数的正实部

r - docker 与 Shiny 的服务器专业版问题

sed - 如何从文本文件中删除多行,包括匹配的行?

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

python - 使用 lxml 将 XML 片段插入 XML 文档