lxml runtime error: Reason: Incompatible library version: etree.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0
Asked Answered
E

6

38

I have a perplexing problem. I have used mac version 10.9, anaconda 3.4.1, python 2.7.6.

Developing web application with python-amazon-product-api. i have overcome an obstacle about installing lxml, referencing clang error: unknown argument: '-mno-fused-madd' (python package installation failure).

But another runtime error happened. Here is the output from webbrowser.

Exception Type: ImportError
Exception Value:    
dlopen(/Users/User_Name/Documents/App_Name/lib/python2.7/site-packages/lxml/etree.so, 2): Library not loaded: libxml2.2.dylib
Referenced from: /Users/User_Name/Documents/App_Name/lib/python2.7/site-packages/lxml/etree.so
Reason: Incompatible library version: etree.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0

I'm not sure how to proceed and have searched here and elsewhere for this particular error.

Estevan answered 19/4, 2014 at 16:15 Comment(1)
I found a solution. I removed virtualenv's library setting. I reinstalled app-required libraries in local ID's python path. Not used virtualenv's setting. Inconvenient but the problem was solved.Estevan
R
11

I was having this same issue. I realized that during pip install for my web app, lxml was attempting the following:

"Building against libxml2/libxslt in the following directory: /Users/[me]/anaconda/lib"

Not 100% sure why, but once I removed the anaconda/bin from my system path in bash_profile (anaconda sticks it in there when installing) I was able to pip install lxml correctly. After which you should be able to re-add anaconda/bin to your system path without issue.

Retinol answered 21/8, 2014 at 20:10 Comment(0)
K
102

This worked for me:

brew install libxml2
brew install libxslt
brew link libxml2 --force
brew link libxslt --force
Kissie answered 24/7, 2015 at 10:9 Comment(4)
Homebrew was the only way that worked for me. Tried all the other suggestions but no good.Odey
Instead of brew link libxml2 --force, you can run echo /usr/local/opt/libxml2/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/libxml2.pth.Espinoza
3rd or 4th time I've needed this, months apart each time. Wish I could upvote 3-4 times haha. Thanks!Gomulka
This worked for me and saved me so much time debugging. THANK YOU!Vanzandt
S
42

If using conda, force a reinstall of lxml:

$ conda install -f lxml

Note that forcing a reinstall may have unforeseen consequences.

I first tried conda update lxml to no effect.

Then tried conda install lxml also to no effect (but that was a while ago and ymmv -- see comment).

Stigmatize answered 10/10, 2014 at 0:9 Comment(1)
'conda install lxml' worked for me (in my case, the '-f' option was not required)... the other answer below (conda install libxml2) did not work.Pantelegraph
R
11

I was having this same issue. I realized that during pip install for my web app, lxml was attempting the following:

"Building against libxml2/libxslt in the following directory: /Users/[me]/anaconda/lib"

Not 100% sure why, but once I removed the anaconda/bin from my system path in bash_profile (anaconda sticks it in there when installing) I was able to pip install lxml correctly. After which you should be able to re-add anaconda/bin to your system path without issue.

Retinol answered 21/8, 2014 at 20:10 Comment(0)
D
8

I get this to work by doing the following:

conda install libxml2
Dorsal answered 20/2, 2015 at 1:51 Comment(0)
F
0

Consider using an alternative channel in conda.

$ anaconda search -t conda pyquery
Using anaconda-server api site https://api.anaconda.org
Run 'anaconda show <USER/PACKAGE>' to get more details:
Packages:
     Name                      |  Version | Package Types   | Platforms      
     ------------------------- |   ------ | --------------- | ---------------
     CS109/pyquery             |    1.2.9 | conda           | linux-64, win-32, win-64, linux-32, osx-64
                                          : A jquery-like library for python
     asmeurer/pyquery          |    1.2.6 | conda           | osx-64         
                                          : https://github.com/gawel/pyquery
     auto/pyquery              |    1.2.8 | conda           | linux-64, linux-32, osx-64
                                          : https://github.com/gawel/pyquery
     dan_blanchard/pyquery     |    1.2.6 | conda           | linux-64       
                                          : https://github.com/gawel/pyquery
     hargup/pyquery            |          | conda           | None-None, linux-64
                                          : A jquery-like library for python
     meloncholy/pyquery        |    1.2.9 | conda           | linux-64       
                                          : A jquery-like library for python
     mhworth/pyquery           |    1.2.8 | conda           | linux-64, osx-64
                                          : A jquery-like library for python
     nbsantos/pyquery          |    1.2.9 | conda           | osx-64         
                                          : A jquery-like library for python
     pdrops/pyquery            |    1.2.8 | conda           | linux-64, osx-64
                                          : A jquery-like library for python
     ziebel/pyquery            |    1.2.9 | conda           | linux-64       
                                          : A jquery-like library for python
Found 10 packages

Then, picking a channel, do:

conda install pyquery -c CS109
Feltner answered 18/11, 2015 at 20:45 Comment(0)
B
0

I tried almost all approaches above and failed. What worked for me was commenting out the

export DYLD_LIBRARY_PATH=/usr/lib

in my bash profile. This line is added by the anaconda installer automatically.

Biologist answered 20/2, 2017 at 8:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.