按理说直接:pip install scrapy
就可以成功,但是出现了错误“libxml/xpath.h: No such file or directory”
“error:failed with exit status 2”
(百度上有很多解决方案而且大多相同,但是都没解决我的问题)
最后还是上官网找解决方法:https://doc.scrapy.org/en/latest/intro/install.html
Scrapy is written in pure Python and depends on a few key Python packages (among others):
- lxml, an efficient XML and HTML parser
- parsel, an HTML/XML data extraction library written on top of lxml,
- w3lib, a multi-purpose helper for dealing with URLs and web page encodings
- twisted, an asynchronous networking framework
- cryptography and pyOpenSSL, to deal with various network-level security need
然后就按着上面的一个一个包下载(因人而异)
如果没有安装Wheel 要先安装:pip install wheel
我只是lxml没有,所以我就只通过:pip install lxml==3.4.2
得到安装包lxml-3.4.2-cp27-none-win32.whl 安装lxml成功!
(这里再说一下我之前因为用命令总安装不成功,就想着直接下.whl文件再安装,但总是下错版本,所以如果上面这个版本你用不了,可以去http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml 这个网站上找对应版本)
最后就可以愉快地:pip install scrapy
安装成功!