【发布时间】:2018-04-17 12:13:43
【问题描述】:
无法从 MAC 上的终端导入 lxml。得到以下错误
错误:
python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 12:01:12)
[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 "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml/etree.so, 2): Symbol not found: _PyUnicodeUCS4_AsASCIIString
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml/etree.so
Expected in: dynamic lookup
>>>
'import lxml' works fine
Python 路径
which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
当我寻找 lxml 安装时,一切看起来都很好
pip install lxml
Requirement already satisfied: lxml in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
pip2 install lxml
Requirement already satisfied: lxml in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
我在这里缺少什么?有什么问题?你能帮帮我吗?
解决方案:
通过卸载lxml 并由pip install lxml --no-binary :all: 重新安装解决了它
【问题讨论】:
标签: macos python-2.7 pip lxml