按照说明直接使用pip install scrapy
会有两个问题:
- fatal error: ‘ffi.h’ file not found
- fatal error: ‘libxml/xmlversion.h’ file not found
这两个文件都是存在的,可是却显示不存在。网上查找后成功解决问题,记录一下:
解决第一个问题:
需要先安装一个homebrew,然后输入
brew install libffi
安装成功后就不会报第一个错误了
解决第二个问题:
在终端输入:
sudo 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 pip install lxml
完成lxml的安装后再执行
pip install scrapy