Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

Please help to fix this.
(Python version ->2.7.5)

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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