在win10的环境下安装scrapy,有些东西是很不同的。html
1.下载安装python2.7(scrapy如今也开始支持python3了)python
2.安装完成以后,把安装路径和脚本路径添加到path中,譬如:C:\Python27\;C:\Python27\Scripts\;python2.7
3.安装pywin32,在下面的链接中下载最新版的pywin32scrapy
http://sourceforge.net/projects/pywin32/files/pywin32/ui
切记,选pywin32 64位版本。.net
若是遇到了错误:python version 2.7 required,which was not found in the registry插件
缘由是注册表不能识别出python2.7,解决方法就是新建一个register.py文件,运行下面的代码code
# # script to register Python 2.0 or later for use with win32all # and other extensions that require Python registry settings # # written by Joakim Loew for Secret Labs AB / PythonWare # # source: # http://www.pythonware.com/products/works/articles/regpy20.htm # # modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html import sys from _winreg import * # tweak as necessary version = sys.version[:3] installpath = sys.prefix regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version) installkey = "InstallPath" pythonkey = "PythonPath" pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % ( installpath, installpath, installpath ) def RegisterPy(): try: reg = OpenKey(HKEY_CURRENT_USER, regpath) except EnvironmentError as e: try: reg = CreateKey(HKEY_CURRENT_USER, regpath) SetValue(reg, installkey, REG_SZ, installpath) SetValue(reg, pythonkey, REG_SZ, pythonpath) CloseKey(reg) except: print "*** Unable to register!" return print "--- Python", version, "is now registered!" return if (QueryValue(reg, installkey) == installpath and QueryValue(reg, pythonkey) == pythonpath): CloseKey(reg) print "=== Python", version, "is already registered!" return CloseKey(reg) print "*** Unable to register!" print "*** You probably have another Python installation!" if __name__ == "__main__": RegisterPy()
运行成功后显示:python 2.7 is already registered,而后再次安装pywin32xml
4.接着安装lxml,并不能直接使用命令pip install lxml来安装,此时就使用第三方的安装方法,到这里(http://www.lfd.uci.edu/~gohlke/pythonlibs/)下载对应的whl文件,切记,要找64位的,还要与python版本相匹配。
而后在存放该下载文件的目录下执行命令:pip install lxml-3.5.0-cp27-none-amd64.whl
5.运行命令:pip install scrapy来安装scrapy,若是遇到以下错误提示:
Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
则到这里:https://www.microsoft.com/en-us/download/details.aspx?id=44266 下载并安装vc++插件
6.全部的障碍都铲除了,你能够放心地使用 pip install scrapy 来安装了。