Python install lxml on mac os 10.10.1

I bought a new macbook and I am so new to mac os. However, I read a lot on the Internet on how to install scrap.

I did everything, but I have a problem installing lxml

I tried this on the terminal

pip install lxml 

and many things started to load, and a lot of text was written on the terminal, but I got this error message on red in the terminal

 1 error generated. error: command '/usr/bin/clang' failed with exit status 1 ---------------------------------------- Cleaning up... Command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools, tokenize;__file__='/private/var/folders/rd/fxgsy46j3l77f6l9h_hv2fjm0000gn/T/pip_build_mycomputername/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/rd/fxgsy46j3l77f6l9h_hv2fjm0000gn/T/pip-WvDTPQ-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/rd/fxgsy46j3l77f6l9h_hv2fjm0000gn/T/pip_build_mycomputername/lxml Storing debug log for failure in /Users/mycomputername/.pip/pip.log 

and now when i call scrapy spider that words with lxml, i got this error message

 ImportError: No module named lxml.html 

what should I do?

any suggestion appreciated

+8
python scrapy lxml macos
source share
2 answers

I had this problem and I did this:

installed all xcode (2.8GB) from the Apple store.

to verify that the installation completed successfully: open a terminal and enter

 xcode-select -p 

you should get something like this:

 /Applications/Xcode.app/Contents/Developer 

Now you need to install the command line tools. try to enter gcc on the terminal, then there are two possibilities: either you get a window asking you to install the tools, and you need to click install , or you get an error message.

if you get an error then don’t worry, just try installing the tools using this xcode-select --install

after that restart mac and then install lxml again as follows:

 pip install lxml 

then try running scrapy again

if you encounter any other error in any other library, just reinstall it with easy_install and NOT using pip

+26
source share

This is likely because you did not reconfigure the command line tools after the upgrade.

Typically, Xcode should be updated to the latest version (4.4) (I believe that when I upgraded to 10.8, I also updated a whole bunch of other applications, including Xcode). After the upgrade, you need to reinstall the command line tools. Now this can be done using the settings in Xcode:

Go to "Settings β†’ Downloads" and install "Command Line Tools".

0
source share

All Articles