You are not logged in.

#1 2010-10-22 10:08:48

jolly_roger
Member
Registered: 2010-10-13
Posts: 6

libxml2 python binding

Hi All,

What is right way of make libxml2 available for python? Does Arch libxml2 package contains binding for python? Now, I have installed libxml2 package (I simply executed "pacman -S libxml2") and when I try to do import of libxml2 to python code ("import libxml2" instruction) I have error that such module isn't found. Do I have to install some additional packages or some additional configuration?

Thanks

Offline

#2 2010-10-22 10:15:18

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,487
Website

Re: libxml2 python binding

> pacman -Ss libxml
...
extra/python-lxml 2.2.8-2
    Python binding for the libxml2 and libxslt libraries

Offline

#3 2010-10-22 10:16:41

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: libxml2 python binding

$ pacman -Ql libxml2 | grep 'lib/python'
libxml2 /usr/lib/python2.7/
libxml2 /usr/lib/python2.7/site-packages/
libxml2 /usr/lib/python2.7/site-packages/drv_libxml2.py
libxml2 /usr/lib/python2.7/site-packages/libxml2.py
libxml2 /usr/lib/python2.7/site-packages/libxml2mod.a
libxml2 /usr/lib/python2.7/site-packages/libxml2mod.so

Offline

#4 2010-10-22 10:27:25

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,941
Website

Re: libxml2 python binding

$ python2 
Python 2.7 (r27:82500, Oct  6 2010, 12:29:13) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2
>>> 

works for me. note the python2

Last edited by wonder (2010-10-22 10:32:47)


Give what you have. To someone, it may be better than you dare to think.

Offline

#5 2010-10-22 19:35:21

jolly_roger
Member
Registered: 2010-10-13
Posts: 6

Re: libxml2 python binding

Seems that on my PC something is wrong.

First of all, as I understand into libxml2 build-in support only for python 2.7.
My output of command "pacman -Ql libxml2 | grep 'lib/python'"

libxml2 /usr/lib/python2.7/
libxml2 /usr/lib/python2.7/site-packages/
libxml2 /usr/lib/python2.7/site-packages/drv_libxml2.py
libxml2 /usr/lib/python2.7/site-packages/libxml2.py
libxml2 /usr/lib/python2.7/site-packages/libxml2mod.a
libxml2 /usr/lib/python2.7/site-packages/libxml2mod.so

So for my python installations it doesn't work

Python 2.6.5 (r265:79063, Apr  1 2010, 05:22:20) 
[GCC 4.4.3 20100316 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named libxml2
Python 3.1.2 (r312:79147, Aug 17 2010, 09:39:49) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named libxml2

And after installing python-lxml, I have no binding

Python 2.6.5 (r265:79063, Apr  1 2010, 05:22:20) 
[GCC 4.4.3 20100316 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml.html
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named lxml.html
Python 3.1.2 (r312:79147, Aug 17 2010, 09:39:49) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml.html
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named lxml.html

Offline

#6 2010-10-22 19:46:26

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,941
Website

Re: libxml2 python binding

something is messed. you still have python 2.6.5


Give what you have. To someone, it may be better than you dare to think.

Offline

#7 2010-10-22 20:29:17

jolly_roger
Member
Registered: 2010-10-13
Posts: 6

Re: libxml2 python binding

I found what was wrong - it was that upgrade was ran a long time ago. After upgrade problem has gone, because python was upgraded to version 2.7

Python 2.7 (r27:82500, Oct  6 2010, 12:18:19) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2
>>> import lxml
>>> import lxml.html

Is there way to use lxml or directly libxml2 in python 3?

Offline

Board footer

Powered by FluxBB