windows下如何成功安裝python scrapy

An open source and collaborative framework for extracting the data you need from websites.html

In a fast, simple, yet extensible way.python

 scrapy是爲了抓取所需的網絡數據的一個開源的協做框架。它的工做方式簡單快速且可擴展。(原諒我耿直的翻譯)web

使用pip安裝scrapy網絡

pip install scrapy

由於個人電腦同時有Python2.7和Python3.5,因此,個人安裝代碼:框架

py -2 -m pip install scrapy

安裝出錯:scrapy

根據提示前往http://aka.ms/vcpython27下載Microsoft Visual C++ Compiler for Python 2.7:ide

安裝了Microsoft Visual C++ Compiler for Python 2.7後,重啓cmd再安裝一次,又出錯:ui

雖然沒有理解錯誤是什麼意思,但大概看出是lxml庫的問題:spa

py -2 -m pip install lxml

報了一樣的錯誤:.net

所以,很明顯是lxml庫致使安裝沒法繼續進行的。我在網上查找了許多方法來解決上面的報錯,都沒有找到根本緣由,因而我在它的官網http://lxml.de/installation.html(我猜想這是官網)找到了一些解釋。

MS Windows

For MS Windows, recent lxml releases feature community donated binary distributions, although you might still want to take a look at the related FAQ entry. If you fail to build lxml on your MS Windows system from the signed and tested sources that we release, consider using the binary builds from PyPI or the unofficial Windows binaries that Christoph Gohlke generously provides.

很明顯這應該是建議我使用非官方的二進制文件來進行安裝,因此我就找到了這個網址:http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml,下載適合Python2.7版本的wheel文件:

【Python Wheel (.whl)文件安裝實踐】

首先應該安裝Python wheel庫:

py -2 -m pip install wheel

而後安裝下載的lxml-3.7.3-cp27-cp27m-win_amd64.whl文件:

在文件所在的位置按住【shift+鼠標右鍵】→【在此處打開命令窗口】,這樣咱們能夠直接進入文件所在的路徑輸命令,固然也能夠用cd來進入文件所在的路徑或者使用帶路徑的文件名。

py -2 -m pip install lxml-3.7.3-cp27-cp27m-win_amd64.whl

 安裝成功。

 

lxml安裝成功後就再也不是咱們安裝scrapy的阻礙了,咱們再次輸入命令:

py -2 -m pip install scrapy

最終scrapy安裝成功,過程當中沒有出現報錯的狀況。

 

查看已經安裝的Python庫:

py -2 -m pip list

 

參考:

  1. https://scrapy.org/【scrapy官網】
  2. http://blog.csdn.net/xibeichengf/article/details/50479151【http://blog.csdn.net/xibeichengf/article/details/50479151】
  3. http://lxml.de/installation.html【lxml官網】
  4. http://lxml.de/FAQ.html#where-are-the-binary-builds【Where are the binary builds?】
  5. http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml【lxml‑3.7.3‑cp27‑cp27m‑win_amd64.whl】
相關文章
相關標籤/搜索