1

When I try importing lxml package in python I am receiving the following error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/lxml/html/__init__.py", line 42, in    <module>
   from lxml import etree
ImportError: /usr/lib/python2.7/dist-packages/lxml/etree.so: undefined symbol:   PyUnicodeUCS4_DecodeLatin1

(Python version ->2.7.5)

2

Python can be compiled in two different modes; UCS2 or UCS4 – see How to find out if Python is compiled with UCS-2 or UCS-4? question at Stackoverflow. All binary packages (like lxml) must be compiled in the same mode that Python was compiled in. It looks like your lxml was compiled in UCS4 mode while Python was compiled in UCS2 mode. You have to recompile one of them so that they use the same mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.