Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install libxml2 and libxslt for python3

Tags:

I tried to install libxml2 and libxslt on ubuntu 16.04 using this command:

sudo apt-get install libxml2-dev libxslt-dev python-dev

when finished I try to import like this:

import libxml2
import libxslt

when I use python2 I can import without problem and when use python3 I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'xmllib2'
like image 503
Oussama He Avatar asked Nov 01 '16 10:11

Oussama He


1 Answers

For the first part: sudo apt-get install python3-libxml2

For libxslt, it is no longer maintained. However, someone has ported it to work with Python3: https://github.com/Unidata/gempak/tree/master/extlibs/xslt/libxslt-1.1.28

It appears that it must be compiled. Here is the documentation stating that it works with Python3: https://gist.github.com/novocaine/ae657bdbf0f25b81e52b

like image 141
RalphyZ Avatar answered Sep 23 '22 16:09

RalphyZ