在win10的環境下安裝scrapy,並不能直接按照官網的手冊(http://doc.scrapy.org/en/1.0/intro/install.html)一次性安裝成功,根據我自己的安裝過程中遇到的問題,特意整理了一下安裝過程 1.下載安裝python2.7.11 https://www.py...
在win10的環境下安裝scrapy,並不能直接按照官網的手冊(http://doc.scrapy.org/en/1.0/intro/install.html)一次性安裝成功,根據我自己的安裝過程中遇到的問題,特意整理了一下安裝過程
1.下載安裝python2.7.11
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/[email protected]/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++插件