遇到了两个大问题,第一个在这里已经解决。
第二个问题是:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
creating build/temp.macosx-10.11-intel-2.7/src/lxml cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/usr/include/libxml2 -Isrc/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.11-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace In file included from src/lxml/lxml.etree.c:323: 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/xmlXPathInitb43sL5.c -o tmp/xmlXPathInitb43sL5.o /tmp/xmlXPathInitb43sL5.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-PmvVPX/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-uPgqEz-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-PmvVPX/lxml |
我使用了这个文章里的解决办法:
1 2 3 4 5 6 7 8 9 10 |
MacBook-Pro:~ EverybodyLies$ sudo STATIC_DEPS=true pip install lxml Password: The directory '/Users/EverybodyLies/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/EverybodyLies/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting lxml Downloading lxml-3.5.0.tar.gz (3.8MB) 100% |████████████████████████████████| 3.8MB 120kB/s Installing collected packages: lxml Running setup.py install for lxml ... done Successfully installed lxml-3.5.0 |
成功安装lxml后,再运行:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
MacBook-Pro:~ EverybodyLies$ sudo pip install Scrapy The directory '/Users/EverybodyLies/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/EverybodyLies/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting Scrapy Downloading Scrapy-1.0.5-py2-none-any.whl (291kB) 100% |████████████████████████████████| 294kB 257kB/s Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /Library/Python/2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): queuelib in /Library/Python/2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /Library/Python/2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.8.0 in /Library/Python/2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): lxml in /Library/Python/2.7/site-packages (from Scrapy) Collecting Twisted>=10.0.0 (from Scrapy) Downloading Twisted-15.5.0.tar.bz2 (3.1MB) 100% |████████████████████████████████| 3.1MB 105kB/s Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /Library/Python/2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): service-identity in /Library/Python/2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in /Library/Python/2.7/site-packages (from pyOpenSSL->Scrapy) Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from Twisted>=10.0.0->Scrapy) Requirement already satisfied (use --upgrade to upgrade): characteristic>=14.0.0 in /Library/Python/2.7/site-packages (from service-identity->Scrapy) Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules in /Library/Python/2.7/site-packages (from service-identity->Scrapy) Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /Library/Python/2.7/site-packages (from service-identity->Scrapy) Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->Scrapy) Requirement already satisfied (use --upgrade to upgrade): ipaddress in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->Scrapy) Requirement already satisfied (use --upgrade to upgrade): setuptools>=1.0 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->Scrapy) Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->Scrapy) Requirement already satisfied (use --upgrade to upgrade): cffi>=1.4.1 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->Scrapy) Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=1.4.1->cryptography>=0.7->pyOpenSSL->Scrapy) Installing collected packages: Twisted, Scrapy Running setup.py install for Twisted ... done Successfully installed Scrapy-1.0.5 Twisted-15.5.0 |
安装成功。