win7 32bit python3.6下安装scrapy

1. pip install scrapy

  Running setup.py install for pycparser ... done
  Running setup.py install for PyDispatcher ... done
  Running setup.py install for zope.interface ... done
  Running setup.py install for Twisted ... error

.....

    building 'twisted.test.raiser' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
出现Twisted安装错误,需要到http://landinghub.visualstudio.com/visual-cpp-build-tools下载Microsoft Visual C++ Build Tools,安装之后,再次运行pip install scrapy成功

2. 创建完成scrapy项目后, 使用scrapy crawl dmoz

dmoz是爬虫名

出现ModuleNotFoundError: No module named 'win32api',说明系统未安装pywin32,从sourceforge上下载于python版本相应的pywin32版本。

3. 安装pywin32,提示找不到python3.6。到注册表查看[HKEY_CURRENT_USER\Software\Python]是否存在,存在的话把这个条目删除。

4. python 运行下面脚本,会在注册表创建python3.6,再次运行pywin32安装程序完成。

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()
5. 至此,scrapy可以成功运行了。

相关软件脚本在:http://pan.baidu.com/s/1dFHwIcT

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值