Friday, September 09, 2016

Python pip Broken After Upgrade To OSx El Capitan

Wow its been a long time since I blogged.  I have no excuse other than things have been a touch crazy.  My work recently started allowing us to upgrade our Mac's from Yosemite to El Capitan.  For me the upgrade only took about 45 minutes, which is pretty quick in the grand scheme of things.  The download is a little over 6 gb and went pretty quickly.  

I was going along fine until today when I tried to install a new module using pip.  About 1/2 way through the installation I was presented with the following output:

    In file included from src/lxml/lxml.etree.c:321:
    src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found
    #include "libxml/xmlversion.h"
             ^
    1 error generated.
    Compile failed: command 'cc' failed with exit status 1
    creating tmp
    cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitf3OxN6.c -o tmp/xmlXPathInitf3OxN6.o
    /tmp/xmlXPathInitf3OxN6.c:1:10: fatal error: 'libxml/xpath.h' file not found
    #include "libxml/xpath.h"
             ^
    1 error generated.
    *********************************************************************************
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
    Perhaps try: xcode-select --install
    *********************************************************************************
    error: command 'cc' failed with exit status 1
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-9IduXA/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-RgavmY-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-9IduXA/lxml/

I had installed other modules last week, but then I realized that that was prior to my upgrading.  I looked at the above output and noticed the line:

     Perhaps try: xcode-select --install

OF COURSE!!!  Although I upgraded, and XCode had been upgraded to, I still needed to do some things with XCode to get things going again.  First, I opened XCode and went through its initial startup after an upgrade.  A bunch of clicking and things were good there.  I then opened up my command line and, prefixing the command with 'sudo', I ran the 'xcode-select --install' command from above.  This presented me a pop-up window to install tools.  So, I accepted and allowed it to install.  Once finished, I tried my pip module installation again and VOILA!!!!  It worked!!!

So, in this lesson, always make sure to update your XCode and xcode-select before moving on after an upgrade.

No comments:

 
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.