win10 安装scrapy

本文提供在Windows 10环境中安装Scrapy的具体步骤,包括Python 2.7.11的安装配置、pywin32安装过程中遇到的问题及解决办法、lxml第三方安装方法、以及安装过程中可能遇到的Microsoft Visual C++ 9.0需求问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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++插件

转载于:https://www.cnblogs.com/kylinlin/p/5173261.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值