I'm trying to do XML validation against some XSD in python. I was successful using lxml package. But the problem starts when I tried to port my code into python 3.4. I tried to install lxml for 3.4 version. Looks like my enterprise linux doesn't play very well with lxml.
pip installation:
pip install lxml
Collecting lxml
Downloading lxml-3.4.4.tar.gz (3.5MB)
100% |################################| 3.5MB 92kB/s
Installing collected packages: lxml
Running setup.py install for lxml
Successfully installed lxml-3.4.4
After pip Installation :
> python
Python 3.4.1 (default, Nov 12 2014, 13:34:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /ws/satjonna-sjc/pyats/lib/python3.4/site-packages/lxml/etree.cpython-34m.so: undefined symbol: xmlMemDisplayLast
>>>
git installation:
git clone git://github.com/lxml/lxml.git lxml
Cloning into 'lxml'...
remote: Counting objects: 25078, done.
remote: Total 25078 (delta 0), reused 0 (delta 0), pack-reused 25078
Receiving objects: 100% (25078/25078), 21.38 MiB | 2.66 MiB/s, done.
Resolving deltas: 100% (9854/9854), done.
Checking connectivity... done.
After git Installation :
> python
Python 3.4.1 (default, Nov 12 2014, 13:34:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'etree'
I found lxml equivalent xml.etree.ElementTree. But the main problem is apart from rewriting the entire code, I need to find an xml.etree alternative for lxml validation moethod ( etree.fromstring(xmlstring, xmlparser) ). Any suggestions to make this work will be really helpful.
lxml
do you have bothlibxml2
andlibxslt
? try:yum install libxml2-devel libxslt-devel
, and installlxml
again – Hobbie