在win10的環境下安裝scrapy,並不能直接按照官網的手冊(http://doc.scrapy.org/en/1.0/intro/install.html)一次性安裝成功,根據我本身的安裝過程當中遇到的問題,特地整理了一下安裝過程html
1.下載安裝python2.7.11python
2.安裝完成以後,把安裝路徑和腳本路徑添加到path中,譬如:C:\Python27\;C:\Python27\Scripts\;python2.7
3.安裝pywin32,在下面的鏈接中下載最新版的pywin32scrapy
http://sourceforge.net/projects/pywin32/files/pywin32/ui
我在安裝pywin32過程當中遇到錯誤提示:spa
python version 2.7 required,which was not found in the registry.net
這是由於註冊表不能識別出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,而後再次安裝pywin32code
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++插件