码迷,mamicode.com
首页 > 其他好文 > 详细

lxml包引入错误

时间:2017-03-25 17:48:33      阅读:503      评论:0      收藏:0      [点我收藏+]

标签:roc   libxml2   lin   make   第三方   view   number   led   and   

在使用第三方包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. >>>   

  安装成功!

lxml包引入错误

标签:roc   libxml2   lin   make   第三方   view   number   led   and   

原文地址:http://www.cnblogs.com/chjbbs/p/6617597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!