我在我的mac上安装了一个lxml,当我输入这样的python时
localhost:lxml-3.0.1 apple$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
File "", line 1, in
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-3.0.1-py2.7-macosx-10.6-intel.egg/lxml/etree.so, 2): Symbol not found: ___xmlStructuredErrorContext
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-3.0.1-py2.7-macosx-10.6-intel.egg/lxml/etree.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-3.0.1-py2.7-macosx-10.6-intel.egg/lxml/etree.so
3 回答
我有同样的问题 . 如果您使用pip安装它,如下所示:
pip install lxml
相反,尝试使用
这解决了我的问题 .
发现于this website
如果您已经安装了
libxml2
,那么's possible that it'只是没有选择正确的版本('s a version installed with OS X by default). In particular, suppose you'已安装libxml2
到/usr/local
. 您可以查看共享库etree.so
引用的内容:在系统安装的版本中检查该符号:
对我来说,它不存在于系统安装的库中 . 但是,在我安装的版本中:
要解决此问题,请确保您的安装路径首先出现在
DYLD_LIBRARY_PATH
中:运行以下命令以安装lxml软件包 .
应该解决这个问题 . 我在MAC OSX 10.7.5上测试过,它工作正常 .