views:

1024

answers:

3

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.

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
+2  A: 

It looks like lxml wants to build an extension that requires access to a C compiler. You will need gcc for that. Try running sudo apt-get install build-essential and that should fix this particular issue.

John Feminella
sudo apt-get install gccsudo: apt-get: command not found
Alex
What OS/distribution is this on?
John Feminella
OSX 10.5.8, python 2.6
Alex
@John The better command for Debain/Ubuntu is `sudo apt-get install build-essential` because it includes tools like make and a few other friends that are usually used in concert with gcc/g++.
gotgenes
Ah. OSX doesn't install the gcc compiler. Get Homebrew (http://github.com/mxcl/homebrew) or its less-intelligent cousin, `ports`, and then install gcc through them instead. Most of your pain is happening because there isn't an official, sensible packager on OS X. Sorry. =/
John Feminella
@gotgenes » You are right. Thank you for the correction; I've updated accordingly.
John Feminella
I tried to mkdir homebrew in /usr/local, but it permission denied me. Usually it just asks for my password.
Alex
OSX 10.5 is bundled with 2.5.1....Perhaps there is a conflict between the two versions....Did you install your own copy of Python 2.6? Might be a PATH issue...
CaseyIT
Yes. I installed Python 2.6. I don't understand what that has to do with getting permission denied when trying to mkdir homebrew from /usr/local.
Alex
+3  A: 

You're missing GCC, as pointed out in the comments, so you require Xcode, since you're on OS X. You can download it from here. Xcode has GCC, as well as make, and all the standard developer tools, plus additional stuff that makes it a whopping gigabyte to download. Whatever. Welcome to Apple's world. Best get started downloading it right this moment.

Also, why did you place the downloaded setuptools in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/? That was totally not in the instructions. The instructions say to download it somewhere, where it's understood somewhere is pretty much any place but /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/. For example, a really good place would be your home directory. After downloading it, you're supposed to run sh setuptools-X.Y.Z.egg, which will then install it properly to the site-packages spot, and put the executable easy_install on your path. If this somehow worked out for you, thank the Maker, but I'd be concerned.

But of course, that's beside the point, because we don't use easy_install anymore. We use pip.

Use distribute and pip

distribute and pip are the new hotness

gotgenes
A: 

Ensure you have libxml2-dev and libxslt1-dev installed

apt-get install libxml2-dev
apt-get install libxslt1-dev

Then your installation should build properly.

Simplecoder