zoukankan      html  css  js  c++  java
  • lxml包引入错误

    在使用第三方包lxml引入etree模块时报错:

    [python] view plain copy
    1. >>> from lxml import etree  
    2. Traceback (most recent call last):  
    3.   File "<stdin>", line 1, in ?  
    4. ImportError: dynamic module does not define init function (initetree)  

       由于之前安装是直接使用源码包进行安装,报错之后决定卸载掉源码安装的版本(直接删除site-packages目录下面的lxml包文件),然后重新使用easy_insall命令安装,安装过程中报错信息如下:

    [sql] view plain copy
    1. ERROR: /bin/sh: xslt-config: command not found  
    2.   
    3. ** make sure the development packages of libxml2 and libxslt are installed **  

        于是分别安装libxml2 and libxslt模块:

    [sql] view plain copy
    1. 1027  yum install libxml2  
    2. 1028  yum install libxslt  

       检查xslt-config命令是否安装成功:

    [sql] view plain copy
    1. [root@oser623 mongodb]# whereis xslt-config  
    2. xslt-config:   
    3. [root@oser623 mongodb]#   

       xslt-config命令还是不存在,在网上找了找资料,提示说需要安装 libxslt-devel

    [sql] view plain copy
    1. 1033  yum install libxslt-devel  

       现在再来尝试安装 lxml模块

    [sql] view plain copy
    1. [root@oser623 mongodb]# whereis xslt-config  
    2. xslt-config: /usr/bin/xslt-config  
    3. [root@oser623 mongodb]# easy_install lxml    
    4. Searching for lxml  
    5. Reading http://pypi.python.org/simple/lxml/  
    6. Reading http://codespeak.net/lxml  
    7. Best match: lxml 2.3.4  
    8. Downloading http://lxml.de/files/lxml-2.3.4.tgz  
    9. Processing lxml-2.3.4.tgz  
    10. Running lxml-2.3.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-zdolOV/lxml-2.3.4/egg-dist-tmp-QQHSfi  
    11. Building lxml version 2.3.4.  
    12. Building without Cython.  
    13. Using build configuration of libxslt 1.1.17  
    14. Building against libxml2/libxslt in the following directory: /usr/lib64  
    15. Adding lxml 2.3.4 to easy-install.pth file  
    16.   
    17. Installed /usr/lib/python2.4/site-packages/lxml-2.3.4-py2.4-linux-x86_64.egg  
    18. Processing dependencies for lxml  
    19. Finished processing dependencies for lxml  

       包导入测试:

    [sql] view plain copy
    1. [root@oser623 mongodb]# python  
    2. Python 2.4.3 (#1, Feb 22 2012, 16:05:45)   
    3. [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2  
    4. Type "help", "copyright", "credits" or "license" for more information.  
    5. >>> from lxml import etree  
    6. >>>   

      安装成功!

  • 相关阅读:
    CodeForces1422A
    C++
    2020第十一届蓝桥杯第一场 B组 C/C++
    Aizu0118
    POJ1979
    monkey 稳定性测试
    adb shell 杀进程以及端口占用,adbserver服务重启失败
    windows查询端口,杀进程
    apk 测试入门基本操作
    解决 genymotion 安装apk报错 app contains ARM native code and your Genymotion device cannot run ARM instructions
  • 原文地址:https://www.cnblogs.com/chjbbs/p/6617597.html
Copyright © 2011-2022 走看看