windows下如何成功安装python scrapy

An open source and collaborative framework for extracting the data you need from websites.

In a fast, simple, yet extensible way.

 scrapy是为了抓取所需的网络数据的一个开源的协作框架。它的工作方式简单快速且可扩展。(原谅我耿直的翻译)

使用pip安装scrapy

pip install scrapy

因为我的电脑同时有Python2.7和Python3.5,所以,我的安装代码:

py -2 -m pip install scrapy

114010_UMPM_1165991.png

安装出错:

114110_y2TQ_1165991.png

根据提示前往http://aka.ms/vcpython27下载Microsoft Visual C++ Compiler for Python 2.7:

114235_aqwm_1165991.png

安装了Microsoft Visual C++ Compiler for Python 2.7后,重启cmd再安装一次,又出错:

115323_NcI5_1165991.png

虽然没有理解错误是什么意思,但大概看出是lxml库的问题:

py -2 -m pip install lxml

报了同样的错误:

115538_YutL_1165991.png

因此,很明显是lxml库导致安装无法继续进行的。我在网上查找了许多方法来解决上面的报错,都没有找到根本原因,于是我在它的官网http://lxml.de/installation.html(我猜测这是官网)找到了一些解释。

MS Windows

For MS Windows, recent lxml releases feature community donated binary distributions, although you might still want to take a look at the related FAQ entry. If you fail to build lxml on your MS Windows system from the signed and tested sources that we release, consider using the binary builds from PyPI or the unofficial Windows binaries that Christoph Gohlke generously provides.

很明显这应该是建议我使用非官方的二进制文件来进行安装,所以我就找到了这个网址:http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml,下载适合Python2.7版本的wheel文件:

131505_D4QS_1165991.png

【Python Wheel (.whl)文件安装实践】

首先应该安装Python wheel库:

py -2 -m pip install wheel

132408_C7uE_1165991.png

然后安装下载的lxml-3.7.3-cp27-cp27m-win_amd64.whl文件:

在文件所在的位置按住【shift+鼠标右键】→【在此处打开命令窗口】,这样我们可以直接进入文件所在的路径输命令,当然也可以用cd来进入文件所在的路径或者使用带路径的文件名。

py -2 -m pip install lxml-3.7.3-cp27-cp27m-win_amd64.whl

132326_JZPT_1165991.png

 安装成功。

 

lxml安装成功后就不再是我们安装scrapy的阻碍了,我们再次输入命令:

py -2 -m pip install scrapy

最终scrapy安装成功,过程中没有出现报错的情况。

 

查看已经安装的Python库:

py -2 -m pip list

132743_48HR_1165991.png

 

参考:

  1. https://scrapy.org/【scrapy官网】
  2. http://blog.csdn.net/xibeichengf/article/details/50479151【http://blog.csdn.net/xibeichengf/article/details/50479151】
  3. http://lxml.de/installation.html【lxml官网】
  4. http://lxml.de/FAQ.html#where-are-the-binary-builds【Where are the binary builds?】
  5. http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml【lxml‑3.7.3‑cp27‑cp27m‑win_amd64.whl】

转载于:https://my.oschina.net/u/1165991/blog/842001

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值