[英]Python3, lxml and “Symbol not found: _lzma_auto_decoder” on Mac OS X 10.9
我已经使用自制软件安装了python 3,然后安装了pip3和lxml。
以下行
来自lxml import entree
导致以下错误:
$ python3
Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 01:12:57)
[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/3.3/lib/python3.3/site- packages/lxml/etree.so, 2): Symbol not found: _lzma_auto_decoder
Referenced from: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/lxml/etree.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/lxml/etree.so
>>> exit();
有人知道如何解决这个问题吗?
我删除了所有版本的python
/Library/Frameworks/Python.framework/Versions/
之后我使用brew重新安装了python 3并使用重新创建了符号链接
brew link --overwrite python3
删除lxml并重新安装lxml第二次为我工作(很奇怪,不满意这个解决方案):
pip3.4 uninstall lxml
pip3.4 install lxml
pip3抱怨已经安装了lxml,用以下命令手动删除安装文件:
rm -fr /private/var/folders/dj/saljfdsf12_sd7s89dfg9080000rb/T/pip_build_user/lxml
然后再说:
pip3.4 install lxml
它奏效了。 我无法重现原始错误消息以找到此问题的根本原因。
如果您使用Homebrew并安装了xz
,则以下内容应该有效:
STATIC_DEPS=true CFLAGS=-I/usr/local/include/lzma pip install -U lxml
否则将CFLAGS设置为lzma标头所在的位置。
我有同样的问题,
我做了什么:
首先,我确保我没有安装端口py27-xml2
, py27-xslt
或py27-lxml
sudo port installed | grep py27
我安装了端口py27-pip
并检查$ PATH变量是否指向它。 还安装了py27-setuptools
。
$ sudo port contents py27-pip | grep /pip$
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
in ~/.bash_profile:
export PATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
$ which pip
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
然后我用easy_install安装了lxml
,它位于与pip
相同的目录中
STATIC_DEPS=true sudo easy_install-2.7 lxml
建设过程显示:
$ STATIC_DEPS=true sudo easy_install-2.7 lxml
Searching for lxml
Reading https://pypi.python.org/simple/lxml/
Downloading
....
Building without Cython.
Using build configuration of libxslt 1.1.29
Building against libxml2/libxslt in the following directory: /Applications/MAMP/Library/
....
libxml/xmlversion.h: No such file or directory
我在$ PATH结束时移动了MAMP(似乎已经附带了这些库),卸载了lxml
(显示“找不到符号:_lzma_auto_decoder”错误)并重复上一个命令:
$ STATIC_DEPS=true sudo easy_install-2.7 -m "lxml==3.6.4"
in ~/.bash_profile:
export PATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/Applications/MAMP/Library/bin:/Applications/MAMP/Library"
$ source ~/.bash_profile
$ STATIC_DEPS=true sudo easy_install-2.7 lxml
这修复了virtualenv
内部或外部的错误
$ python
Python 2.7.12 (default, Jun 29 2016, 12:46:54)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.