无法在 Python 2.7 和 CentOS 7 中导入 libxml2 和 libxslt

Can not import libxml2 and libxslt in Python 2.7 and CentOS 7

无法在 Python 2.7CentOS 7 中导入 libxml2libxslt

但是系统说安装了这些包:

Package libxml2-2.9.1-5.el7_1.2.x86_64 already installed and latest version
Package libxml2-devel-2.9.1-5.el7_1.2.x86_64 already installed and latest version
Package libxslt-1.1.28-5.el7.x86_64 already installed and latest version
Package libxslt-devel-1.1.28-5.el7.x86_64 already installed and latest version

但无法导入 Python2.7

Python 2.7.5 (default, Jun 24 2015, 00:41:19) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named libxml2
>>> import libxslt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named libxslt
>>> 

libxml2安装步骤

yum groupinstall "Development Tools"

yum  install python-devel.x86_64

rpmbuild -ba /usr/src/redhat/SPECS/libxml2.spec (this might not be required.)

##go to  RPMS/x86_64/

rpm -Uvh libxml2-python-2.7.8-1.x86_64.rpm --nodeps

============================================= ======================

libxslt 安装步骤

wget  http://xmlsoft.org/sources/libxslt-1.1.28.tar.gz

cd libxslt-1.1.28

./configure --with-python=/usr/bin/python2.7

make

make install

========================================