windows 安裝Scrapy常見錯誤總結

來源:互聯網
上載者:User

標籤:window scrapy

  寫這篇文章,不僅是為了匯總安裝Scrapy的常見安裝問題,還自己獨立解決問題的能力。從一開始報VS C++版本的錯誤,到後來在CentOS運行pip install lxml很慢(CentOS 7 是一台虛擬機器)。

這是一種常見的安裝lxml的異常情況:


電腦環境:win10 64位

python環境:python 2.7版本 64位系統

目標:安裝lxml  ( lxml-3.6.4-cp27-cp27m-win32.whl)


主要步驟就兩步:

1:安裝工具wheel : pip install wheel

2:安裝lxml:pip install lxml-3.6.4-cp27-cp27m-win32.whl


“預期“”會遇到的坑:

1,記得先安裝wheel工具

2,filename.whl is not supported wheel on this platform

     可以嘗試升級pip工具:python -m pip install --upgrade pip

3,升級工具後應該就沒問題了,需要注意的是lxml的版本:cp27 代表python版本2.7;  win32代表python支援的版本號碼。   lxml版本可到網站自行下載 :http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml


第二種常見安裝異常情況:

注意的是window platform裡pip.exe 的路徑在C:\Python27\scripts\pip.exe


error Microsoft VIsual C++ 9.0 required,按照這個blog(http://www.zhimengzhe.com/windows/112812.html),根據該博文,

一個是在環境變數上修改

650) this.width=650;" src="https://s4.51cto.com/oss/201711/21/04abba7f3834727f27db2d72705fab5c.jpg" title="9ae56df5ac7c8c9a3789e7aadf10db4a.jpg" alt="04abba7f3834727f27db2d72705fab5c.jpg" />

2.修改原始碼

開啟 “python安裝目錄/Lib/distutilsmsvc9compiler.py”檔案,找到find_vcvarsall函數,在該函數開頭添加 

version =上面的版本號碼, 即新增內容為 “VERSION = 14.0”, 這樣就可以使用了

def find_vcvarsall(version):    """Find the vcvarsall.bat file    At first it tries to find the productdir of VS 2008 in the registry. If    that fails it falls back to the VS90COMNTOOLS env var.    """    version = 14.0            ##添加這行    vsbase = VS_BASE % version    ... ...

3.安裝vcforpython27.msi,:https://www.microsoft.com/en-us/download/confirmation.aspx?id=44266


第三種報錯資訊

Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed

fatal error C1083:cannot open include file:libxml/xml.version.h

請參考Stack Overflow

https://stackoverflow.com/questions/33785755/getting-could-not-find-function-xmlcheckversion-in-library-libxml2-is-libxml2


run:

pip install C:\path\to\downloaded\file\lxml-3.6.1-cp27-cp27m-win32.whl


第四種報錯資訊

error: command ‘C:\\Users\\rainer\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe‘ failed with exit status2



,最後在stackoverflow找到解決辦法改用這個命令安裝lxml就好了:set STATICBUILD=true && pip install lxml

原帖地址:http://stackoverflow.com/questions/20460890/lxml-install-on-windows-7-using-pip-and-python-2-7



If you have a compiler installed (tested with VS C++ 2008 Express), you can simply run:

set STATICBUILD=true && pip install lxml

As pointed out on documentation, setting STATICBUILD will tell to lxml‘s installer to automatically download all its binary dependencies before build.

These lxml binary dependencies, that should be present when installing from source, will be downloaded and build together by the installer:

  • libxslt

  • iconv

  • zlib

  • libxml2

Bonus: It also works inside a virtualenv.


像CentOS裡一樣(yum install libxml2-devlibxslt-dev),windows作業系統是否要裝libxml2-dev,libxslt-dev .




pip安裝工具不行就可以換一種安裝工具。

easy_install lxml 


參照這篇博文http://www.cnblogs.com/python-life/articles/4511314.html 安裝在windows系統安裝Scrapy。


安裝Scrapy後,梳理一下:系統給你的報錯資訊很重要,報錯資訊+安裝的關鍵詞(像Scrapy)是輸入到搜尋引擎的重要內容,還有再複雜的事情,分成小步驟來一個一個地完成。

本文出自 “Jason的部落格” 部落格,請務必保留此出處http://jason83.blog.51cto.com/12723827/1983664

windows 安裝Scrapy常見錯誤總結

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.