win10 安装scrapy

在win10的环境下安装scrapy,并不能直接按照官网的手册(http://doc.scrapy.org/en/1.0/intro/install.html)一次性安装成功,根据我自己的安装过程中遇到的问题,特意整理了一下安装过程

1.下载安装python2.7.11

https://www.python.org/

 

2.安装完成之后,把安装路径和脚本路径添加到path中,譬如:C:\Python27\;C:\Python27\Scripts\;

 

3.安装pywin32,在下面的连接中下载最新版的pywin32

http://sourceforge.net/projects/pywin32/files/pywin32/

我在安装pywin32过程中遇到错误提示:

python version 2.7 required,which was not found in the registry

这是因为注册表不能识别出python2.7,解决方法就是新建一个register.py文件,运行下面的代码

#
# 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,然后再次安装pywin32

 

4.接着安装lxml,并不能直接使用命令pip install lxml来安装,此时就使用第三方的安装方法,到这里(http://www.lfd.uci.edu/~gohlke/pythonlibs/)下载文件:

lxml-3.5.0-cp27-none-win32.whl

然后在存放该下载文件的目录下执行命令:pip install lxml-3.5.0-cp27-none-win32.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++插件

posted @ 2016-01-31 14:39  kylinlin  阅读(2791)  评论(0编辑  收藏  举报