Problems installing lxml on Mac, it installs, but the module was not found

The code

from lxml import etree 

causes an error

 ImportError: No module named lxml 

Performance

 sudo easy_install lxml 

leads to

 lxml 2.2.7 is already the active version in easy-install.pth Removing lxml-2.2.7-py2.5-macosx-10.3-i386.egg from site-packages and rerunning sudo easy_install lxml results in Adding lxml 2.2.7 to easy-install.pth file Installed /Library/Python/2.5/site-packages/lxml-2.2.7-py2.5-macosx-10.3-i386.egg Processing dependencies for lxml Finished processing dependencies for lxml 

And still I still don't get a module named lxml

What step am I missing to use lxml on my Mac (OSX 10.5)?

Update

python reports --version

 Python 2.5.2 

and running python creates

 Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin 
+7
python lxml macos
source share
5 answers

It seems you are trying to execute easy_install lxml on the supplied Apple Python 2.5 for OS X 10.5, but using an egg that was probably built using python.org Python 2.5. If you both installed on your system, keep in mind that for each Python you need to have a separate easy_install (setuptools or Distribute). Apple supplies one in /usr/bin for its Python. Make sure you use one python.org (check which python ), you must follow the installation instructions for setuptools or Distribute to set easy_install for it. This easy_install will be located in the bin the python.org structure: /Library/Frameworks/Python.framework/Versions/2.5//bin . Use easy_install to install lxml ; it should end automatically at /Library/Frameworks/Python.framework/Versions/2.5/lib . Below is a more detailed discussion of a similar problem here and here .

+9
source share

You have several versions of python installed on your computer. lxml installed for one and you call the other. Not enough context for the divine anymore.

+2
source share

sudo env ARCHFLAGS="-arch x86_64" easy_install-2.7 lxml

Powered by Mac OS 10.9.

+1
source share

Something is wrong. Package to add: lxml-2.2.7-py2.5-macosx-10.3-i386.egg This applies to mac os x 10.3, while you are using mac os x 10.5.

Try python -version, what does this tell you?

0
source share
 STATIC_DEPS=true sudo pip install lxml 

did the job see http://lxml.de/build.html#building-lxml-on-macos-x

0
source share

All Articles