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.

starball
  • 20,030
  • 7
  • 43
  • 238
BlueFrog
  • 565
  • 1
  • 5
  • 7
  • 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. – BlueFrog Apr 20 '14 at 12:23

6 Answers6

102

This worked for me:

brew install libxml2
brew install libxslt
brew link libxml2 --force
brew link libxslt --force
jessems
  • 1,582
  • 2
  • 11
  • 16
  • 2
    Homebrew was the only way that worked for me. Tried all the other suggestions but no good. – Jason Scott Aug 15 '16 at 06:25
  • 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`. – daviewales Apr 17 '17 at 02:04
  • 3rd or 4th time I've needed this, months apart each time. Wish I could upvote 3-4 times haha. Thanks! – dwanderson Sep 13 '17 at 00:06
  • This worked for me and saved me so much time debugging. THANK YOU! – richddr Jul 31 '18 at 21:42
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).

scharfmn
  • 3,561
  • 7
  • 38
  • 53
  • 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. – nathanielng May 30 '17 at 07:26
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.

daroo
  • 342
  • 4
  • 8
8

I get this to work by doing the following:

conda install libxml2
dvreed77
  • 2,217
  • 2
  • 27
  • 42
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
jbn
  • 651
  • 3
  • 7
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.

Alex Joseph
  • 4,719
  • 2
  • 21
  • 25