安装easy_install ...以开始安装lxml [英] Installing easy_install... to get to installing lxml

查看:92
本文介绍了安装easy_install ...以开始安装lxml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经掌握了ElementTree不会做我想要做的事情的事实.我已经检查了lxml的文档,看来它可以满足我的目的.要获取lxml,我需要获取easy_install.因此,我从此处下载了该文件,然后放入在/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/中.然后我进入那个文件夹,并运行sh setuptools-0.6c11-py2.6.egg.

I've come to grips with the fact that ElementTree isn't going to do what I want it to do. I've checked out the documentation for lxml, and it appears that it will serve my purposes. To get lxml, I need to get easy_install. So I downloaded it from here, and put it in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/. Then I went to that folder, and ran sh setuptools-0.6c11-py2.6.egg.

安装成功.然后,我感到很兴奋,因为我认为easy_install的全部目的就是可以通过easy_install lxml进行安装,而lxml会神奇地正确下载,构建和安装,为我的导入乐趣做好了准备.所以我跑了easy_install lxml.我将结果粘贴到下面.我该怎么办?

That installed successfully. Then I got excited because I thought the whole point of easy_install was that I could then just install via easy_install lxml, and lxml would magically get downloaded, built, and installed properly, ready for my importing enjoyment. So I ran easy_install lxml. I pasted the results below. What should I do?

easy_install lxml
Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.2.6
Downloading http://codespeak.net/lxml/lxml-2.2.6.tgz
Processing lxml-2.2.6.tgz
Running lxml-2.2.6/setup.py -q bdist_egg --dist-dir /var/folders/49/49N0+g5QFKCm51AbzMtghE+++TI/-Tmp-/easy_install-rxbP6K/lxml-2.2.6/egg-dist-tmp-fjakR0
Building lxml version 2.2.6.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' needs to be available.
Using build configuration of libxslt 1.1.12
Building against libxml2/libxslt in the following directory: /usr/lib
unable to execute gcc-4.0: No such file or directory
error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1

推荐答案

首先,我们不再使用easy_install.我们使用 pip .请改用pip.

First off we don't use easy_install anymore. We use pip. Please use pip instead.

正如评论所指出的,要解决您的特定麻烦,您缺少GCC.在OS X上, Xcode 命令行工具提供了GCC以及许多其他必需的程序在OS X上构建软件.对于OS X 10.9(Mavericks)及更高版本,可以通过App Store安装Xcode,或者仅通过以下方式安装Xcode命令行工具:

To get to your particular troubles, as the comments point out, you're missing GCC. On OS X, Xcode Command Line Tools provides GCC, as well as many other programs necessary for building software on OS X. For OS X 10.9 (Mavericks) and newer, either install Xcode through the App Store, or alternatively, install only the Xcode Command Line Tools with

xcode-select --install

有关更多详细信息,请参见

For more details, please see the Apple Developer FAQ or search the web for "install Xcode Command Line Tools".

对于旧版本的OS X,您可以从下载页面的(需要免费注册).

For older versions of OS X, you can get Xcode Command Line Tools from the downloads page of the Apple Developer website (free registration required).

一旦安装了GCC,如果系统上未安装C/C ++库依赖项,则在编译过程中仍可能会遇到错误.在OS X上, Homebrew 项目是安装和管理此类依赖项的最简单方法.按照Homebrew网站上的说明在您的系统上安装Homebrew,然后发出

Once you have GCC installed, you may still encounter errors during compilation if the C/C++ library dependencies are not installed on your system. On OS X, the Homebrew project is the easiest way to install and manage such dependencies. Follow the instructions on the Homebrew website to install Homebrew on your system, then issue

brew update
brew install libxml2 libxslt

可能会导致进一步的麻烦,您将下载的setuptools放置在/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/中.请不要将任何文件下载到此位置.相反,我建议您将文件下载到主目录或通常的Downloads目录.下载后,您应该运行sh setuptools-X.Y.Z.egg,它将随后将其正确安装到相应的site-packages中,并将可执行文件easy_install放在您的路径上.

Possibly causing further trouble in your case, you placed the downloaded setuptools in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/. Please do not download any files to this location. Instead, I suggest you download the file to your home directory, or your usual Downloads directory. After downloading it, you're supposed to run sh setuptools-X.Y.Z.egg, which will then install it properly into the appropriate site-packages and put the executable easy_install on your path.

这篇关于安装easy_install ...以开始安装lxml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆