zoukankan      html  css  js  c++  java
  • CENTOS6.4安装lxml失败

    环境如下:

    • Centos6.4
    • Python 2.7.6

    pip install lxml
    执行上面的命令,有类似下面的提示:

    src/lxml/lxml.etree.c:188133: error: ‘xsltDocDefaultLoader’ undeclared (first use in this function)
    src/lxml/lxml.etree.c:188142: warning: implicit declaration of function ‘xsltSetLoaderFunc’
    src/lxml/lxml.etree.c:188142: error: ‘xsltDocLoaderFunc’ undeclared (first use in this function)
    src/lxml/lxml.etree.c:188142: error: expected ‘)’ before ‘__pyx_f_4lxml_5etree__xslt_doc_loader’
    src/lxml/lxml.etree.c:188393: warning: implicit declaration of function ‘xsltRegisterAllExtras’
    src/lxml/lxml.etree.c:188402: warning: implicit declaration of function ‘exsltRegisterAll’
    error: Setup script exited with error: command 'gcc' failed with exit status 1
    

    像这种情况,一般是对应的devel包没有安装,但是即使我安装了libxml2 和libxml2-devel,还是同样的提示
    已经确认过gcc, gcc-c++等基础包安装的了

    [root@localhost]$ rpm -qa |grep gcc
    gcc-4.4.7-4.el6.x86_64
    libgcc-4.4.7-4.el6.x86_64
    gcc-c++-4.4.7-4.el6.x86_64
    

    查看pypi上lxml的文档 lxml 3.4.1,可以在第一段就看到下面的一句话:

    Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
    

    这里指出了lxml 会使用到 libxml2/libxsl

    yum search libxml 
    yum search libxsl
    会发现有libxslt-devel和libxml2-devel
    

    执行shell命令:

    yum -y install libxslt-devel
    

    上面的命令执行之后,会自动安装和更新如下的软件包:

    1. libxml2
    2. libxml2-devel
    3. libgpg-error-devel
    4. libgcrypt-devel
    5. libxslt
    6. libxslt-devel

    安装上面了6个软件包之后,pip install lxml就能成功安装lxml了

  • 相关阅读:
    2015年要做的150件事
    再见2014,你好2015
    页面滚动事件的使用
    简单的进度条演示
    mybatis foreach批量处理
    mysql执行顺序
    spring声明式事务 同一类内方法调用事务失效
    Semaphore
    springmvc使用JSR-303对复杂对象进行校验
    springmvc全局异常后返回JSON异常数据
  • 原文地址:https://www.cnblogs.com/xupeiyuan/p/4246828.html
Copyright © 2011-2022 走看看