python安裝lxml,在windows環境下

windows環境下真是折騰。

直接pip install lxml,會報錯,

看提示:“make sure the development packages of libxml2 and libxslt are installed” 意識到有依賴,

於是就pip install libxml2..結果就懵逼了 = =,原來不是Python庫。

Collecting libxml2
  Could not find a version that satisfies the requirement libxml2 (from versions: )
No matching distribution found for libxml2

翻了好久,左拐又拐,各種嘗試,最後才發現這個地址http://lxml.de/installation.html ,官方安裝說明,

You need Python 2.6 or later.

libxml2 version 2.7.0 or later.

libxslt version 1.1.23 or later.

在linux下安裝的過程跳過,可以參考文檔說明

在windows下,建議是直接使用二進制文件安裝。

unofficial Windows binaries:http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

隨便下了一個,在pip install *whl 失敗!提示說平臺不支持,又蒙了

 is not a supported wheel on this platform

原來,lxml-3.4.4-cp34-none-win32.whl ,cp34對應不同的Python版本支持,需要查看自己的Python版本支持情況:

import pip; print(pip.pep425tags.get_supported())

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip; print(pip.pep425tags.get_supported())
[('cp34', 'none', 'win32'), ('py3', 'none', 'win32'), ('cp34', 'none', 'any'), (
e', 'any'), ('cp32', 'none', 'any'), ('cp31', 'none', 'any'), ('cp30', 'none', '
3', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', '
')]

顯然,用cp34-none-win32纔可以

pip install lxml-3.4.4-cp34-none-win32.whl

windows環境下成功安裝lxml。

Processing d:\order\lxml-3.4.4-cp34-none-win32.whl
Installing collected packages: lxml
Successfully installed lxml-3.4.4

最終是成功解決了,但是這個過程卻有些意外,有必要記錄一下,也算是漲經驗了。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章