win10 安裝scrapy


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM