unable to import libxml2mod from the python script (on the browser)

376 views
Skip to first unread message

Superman

unread,
Jun 2, 2010, 9:56:46 AM6/2/10
to scrapy-users
I have a django site that is integrated with scrapy, but when the
scrapy code is called from the view, I get this error:

File "/usr/local/lib/python2.5/site-packages/libxml2.py", line 1, in
<module>
import libxml2mod

ImportError: /usr/local/lib/python2.5/site-packages/
libxml2mod.so:
undefined symbol:xmlTextReaderSetup

But using the same python executable file on shell, I can import
libxml2 and libxml2mod fine!

>>> import libxml2mod
>>> import libxml2
>>>

Does anyone have an idea why my program is not working from .py file
as import is working perfect from python prompt.

Pablo Hoffman

unread,
Jun 2, 2010, 3:53:51 PM6/2/10
to scrapy...@googlegroups.com
It looks like a problem with the libxml2 library installed in your system. What
distro are you using?. Are you using the libxml2 & python-libxml2 packages that
come with your distro or you have installed manually?

> --
> You received this message because you are subscribed to the Google Groups "scrapy-users" group.
> To post to this group, send email to scrapy...@googlegroups.com.
> To unsubscribe from this group, send email to scrapy-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/scrapy-users?hl=en.

Superman

unread,
Jun 2, 2010, 4:20:21 PM6/2/10
to scrapy-users
I installed them manually. I'm using libxml2 version 2.7.3, and
libxml2-python bindings version 2.6.21. Run ldconfig on the libraries,
and they seem to be linked correctly.

What stumps me is that libxml2 and libxml2mod modules are imported
fine in shell, using the same interpreter. However, when run in a
browser, it fails to import libxml2mod.

Btw, im on a linux server. Any suggestions to get out of this problem
is greatly appreciated! ( I have been at this for days)

Pablo Hoffman

unread,
Jun 3, 2010, 9:35:56 AM6/3/10
to scrapy...@googlegroups.com
On Wed, Jun 02, 2010 at 01:20:21PM -0700, Superman wrote:
> I installed them manually. I'm using libxml2 version 2.7.3, and
> libxml2-python bindings version 2.6.21. Run ldconfig on the libraries,
> and they seem to be linked correctly.

Hmm... I think you should be using the same libxml2 and libxml2-python version.
It's meant to be used that way, otherwise nasty things could happend like the
issue you're experiencing.

> What stumps me is that libxml2 and libxml2mod modules are imported
> fine in shell, using the same interpreter. However, when run in a
> browser, it fails to import libxml2mod.
>
> Btw, im on a linux server. Any suggestions to get out of this problem
> is greatly appreciated! ( I have been at this for days)

Any chance you could upgrade to a newer distro? Or use a different server for
this?

Pablo.

Superman

unread,
Jun 3, 2010, 10:15:35 AM6/3/10
to scrapy-users
RESOLVED!!!

Thanks for your help Pablo. You are probably right about the libxml2
and libxml2-python versions conflicting. I now downgraded to libxml2
version 2.6.8 working with libxml2-python version 2.6.21. And the .py
executable complained of no libxml2.XML_PARSE_RECOVER module. I
reluctantly hacked into libxml2.py file and added the line
XML_PARSE_RECOVER = 1. And everything seems to be working fine, except
that now the shell outputs the same error that the .py executable
complained of before. Do you have any idea why that is?

So, the way I see it is one way or the other. But am happy that my
django site works well with scrapy and does what is needed.

PS: I really like working with scrapy and the documentation is really
neat.
Reply all
Reply to author
Forward
0 new messages