If you installed libxml2 , then itβs possible that it just doesnβt pick the correct version (the OS X version is installed by default). In particular, suppose you installed libxml2 in /usr/local . You can check which common etree.so libraries link:
$> otool -L /Library/Python/2.7/site-packages/lxml-3.2.1-py2.7-macosx-10.7-intel.egg/lxml/etree.so /Library/Python/2.7/site-packages/lxml-3.2.1-py2.7-macosx-10.7-intel.egg/lxml/etree.so: /usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.24.0) /usr/local/lib/libexslt.0.dylib (compatibility version 9.0.0, current version 9.17.0) /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.3.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
Checking this symbol in the system version:
$> nm /usr/lib/libxml2.2.dylib | grep ___xmlStructuredErrorContext
For me, this is not present in the system library. However, in the version I installed,
$> nm /usr/local/lib/libxml2.2.dylib | grep ___xmlStructuredErrorContext 000000000007dec0 T ___xmlStructuredErrorContext
To solve this problem, first make sure that the installation path is specified in DYLD_LIBRARY_PATH :
$> export DYLD_LIBRARY_PATH=/usr/local/lib $> python >>> from lxml import etree
Dan lecocq
source share