You are not logged in.
Pages: 1
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
> pacman -Ss libxml
...
extra/python-lxml 2.2.8-2
Python binding for the libxml2 and libxslt libraries
Offline
$ 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
$ 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
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
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
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
Pages: 1