繁体   English   中英

如何在Mac OS X 10.7.4上安装lxml? 我已经筋疲力尽了

[英]How do I install lxml on Mac OS X 10.7.4? I have exhausted all options

试过各种途径,但没有运气。 我正在使用10.7.4的MBP。 我不记得上次我在Mac上用Python安装任何东西时遇到这么多问题。 请帮我在我的本地机器上使用lxml,而不是依靠SVN提交,在Linux机器上远程运行更新。

$ sudo STATIC_DEPS=true /usr/bin/easy_install-2.7 lxml
Password:
Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.3.4
Downloading http://lxml.de/files/lxml-2.3.4.tgz
Processing lxml-2.3.4.tgz
Running lxml-2.3.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-mbyEtk/lxml-2.3.4/egg-dist-tmp-O_t_3P
Building lxml version 2.3.4.
Latest version of libiconv is 1.14
Downloading libiconv into libs/libiconv-1.14.tar.gz
error: [Errno 60] Operation timed out

尝试以下没有运气

$ python setup.py build

$ STATIC_DEPS=true sudo easy_install --allow-hosts=lxml.de,*.python.org lxml
$ sudo pip install lxml

llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.7-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace

unable to execute llvm-gcc-4.2: No such file or directory

error: command 'llvm-gcc-4.2' failed with exit status 1

我首先安装了MacPorts然后:

$ sudo port install python27 py27-lxml

这给了我一个正常运行的lxml安装。

关于您的错误消息,您似乎缺少pip用于构建lxml (llvm-gcc-4.2)的编译器命令。 您是否安装了OS X开发工具? 你应该在/usr/bin/llvm-gcc-4.2找到该文件; 如果它不存在,您可能需要下载并安装开发包。

您可以通过App Store安装XCode开发人员工具。 如果您阅读应用商店中的注释,您会注意到为了使命令行工具可用,您需要单独安装它们。 在XCode中,转到Preferences-> Downloads并下载“命令行工具”包。

对于正在浏览此页面的未来用户,以下是在Mac OSX上安装lxml的分步指南。

  1. 转到Xcode,然后转到“首选项”,然后转到“下载”选项卡,并选择“命令行工具”。 下载命令行工具

  2. 转到应用程序,然后转到实用程序,然后转到终端,然后打开终端。 在终端中,输入“easy_install pip”。 注意:如果显示“error:/ usr / local / bin / pip:Permission denied”,则键入“chmod 777 / usr / local / bin /”。 现在再次尝试第2步。

  3. 键入:pip install“Cython> = 0.18”

  4. 完成后,输入:pip install lxml

  5. 打开python IDLE并测试你是否可以导入lxml,玩得开心!

我不得不这样做:“ sudo port uninstall py-lxml ”,“ sudo port uninstall py24-lxml ”,和“ sudo port install py27-lxml ”然后我用pip卸载lxml,并用pip重新安装它就可以了!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM