1. 程式人生 > >win10下基於python3.5安裝scrapy教程

win10下基於python3.5安裝scrapy教程

1、安裝pywin32

pip install pywin32-220.1-cp35-cp35m-win32.whl
2、安裝twisted
pip install Twisted-16.5.0-cp35-cp35m-win32.whl

3、安裝 scrapy

pip install scrapy

在這一步的安裝中出現以下報錯:

Command "c:\users\springlustre\appdata\local\programs\python\python35-32\python.exe -u -c "import setuptools, tokenize;_
_file__='C:\\Users\\SPRING~1\\AppData\\Local\\Temp\\pip-build-u69illst\\lxml\\setup.py';f=getattr(tokenize, 'open', open
)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Use
rs\SPRING~1\AppData\Local\Temp\pip-serz1p13-record\install-record.txt --single-version-externally-managed --compile" fai
led with error code 1 in C:\Users\SPRING~1\AppData\Local\Temp\pip-build-u69illst\lxml\

原因是在windows環境中,呼叫的vcvarsall.bat的檔案在c++程式設計環境才會有。網上的解決方法有兩個:一是安裝MinGW;二是安裝Visual Studio ,我用的是第二種

   下載安裝visio studio 

再次安裝報錯

 C:\Users\SPRING~1\AppData\Local\Temp\xmlXPathInit5xdue4a3.c(1): fatal error C1083: 無法開啟包括檔案: “libxml/xpath.
: No such file or directory
 *********************************************************************************
 Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
 *********************************************************************************
 error: command 'E:\\Program Files\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

執行命令  pip install lxml

執行的時候 報錯

  File "c:\users\springlustre\appdata\local\programs\python\python35-32\lib\site-packages\scrapy\downloadermiddlewares\r
etry.py", line 23, in <module>
    from scrapy.xlib.tx import ResponseFailed
  File "c:\users\springlustre\appdata\local\programs\python\python35-32\lib\site-packages\scrapy\xlib\tx\__init__.py", l
ine 3, in <module>
    from twisted.web import client
  File "c:\users\springlustre\appdata\local\programs\python\python35-32\lib\site-packages\twisted\web\client.py", line 4
2, in <module>
    from twisted.internet.endpoints import TCP4ClientEndpoint, SSL4ClientEndpoint
  File "c:\users\springlustre\appdata\local\programs\python\python35-32\lib\site-packages\twisted\internet\endpoints.py"
, line 36, in <module>
    from twisted.internet.stdio import StandardIO, PipeAddress
  File "c:\users\springlustre\appdata\local\programs\python\python35-32\lib\site-packages\twisted\internet\stdio.py", li
ne 30, in <module>
    from twisted.internet import _win32stdio
  File "c:\users\springlustre\appdata\local\programs\python\python35-32\lib\site-packages\twisted\internet\_win32stdio.p
y", line 9, in <module>
    import win32api
ImportError: DLL load failed: 找不到指定的模組。
後來發現是win32的問題,現在已經改成pypiwin32了,