在win10環境下安裝Scrapy的步驟

在win10的環境下安裝scrapy,有些東西是很不同的。html

1.下載安裝python2.7(scrapy如今也開始支持python3了)python

https://www.python.org/c++

 

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 來安裝了。

相關文章
相關標籤/搜索