【问题标题】:Setup.py: install lxml with Python2.6 on CentOSSetup.py:在 CentOS 上用 Python2.6 安装 lxml
【发布时间】:2011-06-06 06:56:52
【问题描述】:

我已经在 CentOS 5.4 上安装了 Python 2.6.6,

[@SC-055 lxml-2.3beta1]$ python
Python 2.6.6 (r266:84292, Jan  4 2011, 09:49:55) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

我想使用 lxml 模块,但是从源代码构建失败:

src/lxml/lxml.etree.c:157929: error: ‘xsltLibxsltVersion’ undeclared (first use in this function)
src/lxml/lxml.etree.c:157941: error: ‘__pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER’ undeclared (first use in this function)
src/lxml/lxml.etree.c:157941: error: ‘xsltDocDefaultLoader’ undeclared (first use in this function)
src/lxml/lxml.etree.c:157950: error: ‘__pyx_f_4lxml_5etree__xslt_doc_loader’ undeclared (first use in this function)
error: command 'gcc' failed with exit status 1

【问题讨论】:

  • 机器上安装了什么版本的 libxslt 头文件?

标签: python lxml python-2.6 python-import centos5


【解决方案1】:

我遇到了同样的问题,我在安装包 libxslt-develpython-devel 后设法安装它,这似乎是你的问题:

yum install libxslt-devel python-devel

python setup.py install

Installed /usr/lib/python2.6/site-packages/lxml-2.2.8-py2.6-linux-i686.egg
Processing dependencies for lxml==2.2.8
Finished processing dependencies for lxml==2.2.8

但是,由于我在此过程中还安装了其他软件包,因此您可能需要仔细检查 libxml2libxml2-devellibxslt

这里有一些关于如何构建 lxml 的信息:http://lxml.de/build.html

【讨论】:

  • 非常感谢~ 1 $ sudo yum install libxslt-devel 2. $ sudo easy_install lxml 并且它可以工作~
  • 仅供参考 - Ubuntu 上的相同问题已修复 -> apt-get install libxslt1-dev
  • centos 上的python-devel(ubuntu 上的python-dev)也是必需的。
  • # python setup.py install python: can't open file 'setup.py': [Errno 2] No such file or directory
  • @realtebo 您必须先将cd 放入您拥有setup.py 的文件夹中(您下载/解压缩包的位置)
【解决方案2】:

它解决了我在 Centos 中 nokogiri 的问题

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel

【讨论】:

    【解决方案3】:

    这些对我有用

    yum -y install python-devel gcc libxml2 libxml2-devel libxslt libxslt-devel
    

    尤其是python-devel

    【讨论】:

      【解决方案4】:

      如果下面的不行

      sudo yum install libxslt-devel python-devel
      

      试试这个

      pip install -U pip setuptools
      

      然后安装

      pip install lxml
      

      【讨论】:

        猜你喜欢
        • 2014-01-20
        • 1970-01-01
        • 1970-01-01
        • 2018-06-07
        • 2013-12-12
        • 2011-02-02
        • 1970-01-01
        • 2014-11-28
        • 2012-03-14
        相关资源
        最近更新 更多