Python installation lxml error Xmlversion.h not found error solution in MacOS

Source: Internet
Author: User

Recently looking at an automated testing framework of the problem, need to use the lxml library, download lxml always error.

1, install lxml using PIP

Install lxml

2, and then error, the error content is:

InchfileIncluded from src/lxml/lxml.etree.c:139: src/lxml/etree_defs.h:9:Ten: Fatal error:'Libxml/xmlversion.h' fileNot found#include"Libxml/xmlversion.h"^1Error Generated.error:command'cc'Failed with exit status1----------------------------------------Cleaning Up...command/usr/bin/python-c"import setuptools, tokenize;__file__= '/private/var/folders/rc/0lpvj1710n332qg8p2wgcqyr0000gn/t/pip_build_ Cindy_mac/lxml/setup.py '; Exec (Compile (getattr (tokenize, ' open ', open) (__file__). Read (). replace (' \ r \ n ', ' \ n '), __ file__, ' exec '))" Install--record/var/folders/rc/0lpvj1710n332qg8p2wgcqyr0000gn/t/pip-xwdvzy-record/Install-record.txt--single-version-externally-managed--compile failed with error code1 inch/private/var/folders/rc/0lpvj1710n332qg8p2wgcqyr0000gn/t/pip_build_cindy_mac/lxmlstoring Debug Log forFailureinch/users/cindy_mac/library/logs/pip.log

3, then Baidu has n long N long, borrowed from a great God's plan, http://blog.marchtea.com/archives/91

4, find into Application->xcode, right-click: display Content , follow the following code path step by step: Copy path:/applications/xcode.app/contents/ Developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/include

Then enter in the terminal:

c_include_path=/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10. 9. sdk/usr/include/libxml2:/applications/xcode.app/contents/developer/platforms/macosx.platform/ developer/sdks/macosx10. 9. Sdk/usr/include/libxml2/libxml:/applications/xcode.app/contents/developer/platforms/macosx.platform /developer/sdks/macosx10. 9. sdk/usr/include

5, then use PIP to install again

Install lxml

6, see the Success!!! I have tears to stay ...

downloading/unpacking lxml downloading lxml-3.4.1.Tar. GZ (3.5MB):3. 5MB downloaded Running setup.py (path:/private/var/folders/rc/0lpvj1710n332qg8p2wgcqyr0000gn/t/pip_build_cindy_mac/lxml/setup.py) Egg_info forPackage lxml/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/distutils/dist.py:267: Userwarning:unknown distribution option:'Bugtrack_url'Warnings.warn (msg) Building lxml version3.4.1.    Building without Cython. Using build configuration of Libxslt1.1. -Warning:no previously-included Files found matching'*.py'installing collected packages:lxml Running setup.pyInstall  forlxml/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/distutils/dist.py:267: Userwarning:unknown distribution option:'Bugtrack_url'Warnings.warn (msg) Building lxml version3.4.1.    Building without Cython. Using build configuration of Libxslt1.1. -Building'lxml.etree'extensioncc-fno-strict-aliasing-fno-common-dynamic-arch X86_64-arch i386-g-os-pipe-fno-common-fno-strict-aliasing-fwrapv-d enable_dtrace-dmacosx-dndebug-wall-wstrict-prototypes-wshorten- --to- +-dndebug-g-fwrapv-os-wall-wstrict-prototypes-denable_dtrace-arch X86_64-arch i386-pipe-i/usr/include/libxml2-i/ private/var/folders/rc/0lpvj1710n332qg8p2wgcqyr0000gn/t/pip_build_cindy_mac/lxml/src/lxml/includes-i/system/ library/frameworks/python.framework/versions/2.7/include/python2.7-C Src/lxml/lxml.etree.c-o build/temp.macosx-10.9-intel-2.7/SRC/LXML/LXML.ETREE.O-W-Flat_namespacecc-bundle-undefined dynamic_lookup-arch x86_64-arch i386-wl,-f. build/temp.macosx-10.9-intel-2.7/src/lxml/lxml.etree.o-lxslt-lexslt-lxml2-lz-lm-o build/lib.macosx-10.9-intel-2.7/lxml/etree.so Building'lxml.objectify'extensioncc-fno-strict-aliasing-fno-common-dynamic-arch X86_64-arch i386-g-os-pipe-fno-common-fno-strict-aliasing-fwrapv-d enable_dtrace-dmacosx-dndebug-wall-wstrict-prototypes-wshorten- --to- +-dndebug-g-fwrapv-os-wall-wstrict-prototypes-denable_dtrace-arch X86_64-arch i386-pipe-i/usr/include/libxml2-i/ private/var/folders/rc/0lpvj1710n332qg8p2wgcqyr0000gn/t/pip_build_cindy_mac/lxml/src/lxml/includes-i/system/ library/frameworks/python.framework/versions/2.7/include/python2.7-C Src/lxml/lxml.objectify.c-o build/temp.macosx-10.9-intel-2.7/SRC/LXML/LXML.OBJECTIFY.O-W-Flat_namespacecc-bundle-undefined dynamic_lookup-arch x86_64-arch i386-wl,-f. build/temp.macosx-10.9-intel-2.7/src/lxml/lxml.objectify.o-lxslt-lexslt-lxml2-lz-lm-o build/lib.macosx-10.9-intel-2.7/lxml/objectify.so successfully installed lxmlcleaning up ...

7, for insurance, and then test it:

cindy-macdemacbook-pro:users cindy_mac$ Pythonpython2.7.5(Default, Mar9  the, A: the: to) [GCC4.2.1Compatible Apple LLVM5.0(clang-500.0. the)] on Darwintype" Help","Copyright","credits"Or"License"  for  Moreinformation.>>>Import lxml>>> exit ()

Without an error, I'd be happy.

The solution for installing lxml error Xmlversion.h not found error in Python under MacOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.