libxml2 ImportError when importing etree from lxml
Asked Answered
S

2

7

I am trying to run python-docx in Enthought Canopy. I'm running Ubuntu 14.04 on VMWare Worstation 10. Whenever I try to import docx or import etree from lxml, I get an error that seems to be related to the libxml2 library:

ImportError: /usr/lib/x86_64-linux-gnu/libxslt.so.1: symbol xmlBufUse, version   LIBXML2_2.9.0 not defined in file libxml2.so.2 with link time reference

I checked around, and found another person with a similar error, and I followed the directions. Still no luck. Then I realized that I have libxml2 version 2.9.1 on my computer.

Does this mean that I need to get the older 2.9.0 version of libxml2, or is something else going on? I can find 2.9.1 with apt-get, but not 2.9.0. Before setting off on that path, I figured someone here might have a better idea.

Thanks!

Shunt answered 11/7, 2014 at 1:52 Comment(1)
Probably a better question for askubuntu.comDodecanese
V
11

Just install below package.

For Ubuntu

apt-get install libxslt-dev

For Centos

yum install libxslt-devel
Viniferous answered 11/11, 2016 at 6:46 Comment(1)
Please give some explanation to your answer. Its generally considered bad to just say "install this" since it could be a dangerous command &/or impact other services.Tajuanatak
S
1

I don't have much expertise with Ubuntu, but this problem is definitely between lxml and libxml2 and/or libxslt. The only reason it's happening when running python-docx is because that causes lxml to be imported.

I would try uninstalling lxml and reinstalling. I vaguely remember lxml hard-linking with libxml2 and libxslt, but that was a while ago. It's plausible there's a version mis-match between what lxml linked with and the installed versions.

If that didn't do the trick I'd look deeper at the libxml2 and libxslt install. There's some popular advice on that here: How to install lxml on Ubuntu

python-docx isn't going to be terrifically picky about having the very latest lxml package, if there's one you can get with apt it should work just fine.

Sondra answered 11/7, 2014 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.