WebFaction
Community site: login faq

I've installed lxml, but I get an error when I try to use lxml.html.clean.clean_html:

>>> from lxml.html.clean import clean_html
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/anarres/lib/python2.7/lxml-2.3-py2.7-linux-i686.egg/lxml/html/__init__.py", line 12, in <module>
    from lxml import etree
ImportError: /home/anarres/lib/python2.7/lxml-2.3-py2.7-linux-i686.egg/lxml/etree.so: undefined symbol: libiconv

It seems there is a problem with the etree module. Any ideas of how to fix this?

asked 28 May '11, 11:38

anarres
122
accept rate: 0%

I just installed lxml for Python2.7 in a test account and ran the same import without getting this traceback.

How did you install lxml?

(28 May '11, 11:50) David L ♦♦

In reply to David, I installed lxml like this:

$ mkdir $HOME/tmp     
$ export TEMP=$HOME/tmp     
$ CFLAGS="$CFLAGS -lgcrypt -fPIC" STATIC_DEPS=true easy_install-2.7

A lot of code ran down the screen and then I got a message that the file /home/anarres/lib/python2.4/lxml-2.3-py2.7-linux-i686.egg had been created. So I did this:

$ easy_install /home/anarres/lib/python2.7/lxml-2.3-py2.7-linux-i686.egg

And I got the following response:

Processing lxml-2.3-py2.7-linux-i686.egg     
Copying lxml-2.3-py2.7-linux-i686.egg to /home/anarres/lib/python2.4     
Removing lxml 2.3 from easy-install.pth file Adding lxml 2.3 to easy-install.pth file    
Installed /home/anarres/lib/python2.4/lxml-2.3-py2.7-linux-i686.egg     
Processing dependencies for lxml==2.3
permanent link
This answer is marked "community wiki".

answered 28 May '11, 12:23

anarres
122
accept rate: 0%

You installed it to python2.4

Replace the easy_install command with, easy_install-2.7

(28 May '11, 12:32) johns

Thanks, per the suggestion from Johns I tried to install lxml to python-2.7, but I'm still getting the same problem. I did this:

$ easy_install-2.7 /home/anarres/lib/python2.7/lxml-2.3-py2.7-linux-i686.egg

and got this response:

Processing lxml-2.3-py2.7-linux-i686.egg
lxml 2.3 is already the active version in easy-install.pth

Installed /home/anarres/lib/python2.7/lxml-2.3-py2.7-linux-i686.egg
Processing dependencies for lxml==2.3
Finished processing dependencies for lxml==2.3

But when I try to import etree I still get an error.

>>> from lxml import etree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home/anarres/lib/python2.7/lxml-2.3-py2.7-linux-i686.egg/lxml/etree.so: undefined symbol: libiconv
permanent link

answered 28 May '11, 13:09

anarres
122
accept rate: 0%

Remove the current egg and than use a different egg or the default egg,

[me@webx ~]$ easy_install-2.7 lxml
Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.3
Downloading http://lxml.de/files/lxml-2.3.tgz
Processing lxml-2.3.tgz
Running lxml-2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-S2wBnr/lxml-2.3/egg-dist-tmp-0jyFds
Building lxml version 2.3.
Building without Cython.
Using build configuration of libxslt 1.1.17
Building against libxml2/libxslt in the following directory: /usr/lib
Adding lxml 2.3 to easy-install.pth file

Installed /home/lucidsky/lib/python2.7/lxml-2.3-py2.7-linux-i686.egg
Processing dependencies for lxml
Finished processing dependencies for lxml
[me@webx ~]$ python2.7
Python 2.7.1 (r271:86832, Dec  1 2010, 06:29:57) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>>
permanent link

answered 28 May '11, 13:19

johns
5.4k312
accept rate: 23%

Thanks very much, it works now. I guess I just needed to delete the old .egg directory.

(30 May '11, 06:48) anarres
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×52
×9
×1

question asked: 28 May '11, 11:38

question was seen: 7,749 times

last updated: 30 May '11, 06:48

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM