pip 的安裝方法:
首先下載get-pip.py
然后執行:
python get-pip.py
一般在python中安裝模塊,可以使用pip install lib_name
.
如果安裝的過程中,提示```
running build_ext
building 'lxml.etree' extension
error: Unable to find vcvarsall.bat
這里提示的錯誤包含兩個信息,
* 需要安裝lxml擴展
* 找不到vcvarsall.bat 文件。
井搜索發現,網上大部分的建議是:
>安裝Visual Studio 2010,并且設置一個環境變量SET VS90COMNTOOLS=%VS100COMNTOOLS%
但是安裝Visual Studio 2010又異常麻煩,能不能繞過此呢?
當然可以,可以通過`*.whl`二進制文件進行安裝。
這些二進制文件一般可以通過下面兩個平臺進行搜索:
* [PyPi](https://pypi.python.org/pypi)
* [[Unofficial Windows Binaries for Python Extension Packages](http://www.lfd.uci.edu/~gohlke/pythonlibs/)](http://www.lfd.uci.edu/~gohlke/pythonlibs/)
通過在這兩個頁面搜索相應的模塊,找到下載頁面中對應操作系統對應python版本好的whl文件。
### 安裝
將下載好的whl文件,拷貝到對應python的script目錄下,執行:
> pip install *.whl
如果提示:
> *.whl is not a supported wheel on this platform.
你需要檢查使用的pip和你下載安裝的whl是不是對應的。也就是說,如果你安裝了python2.7,又安裝了python3.2,你要下載安裝python2.7的whl文件,而你使用的確實python3.2下面的pip,就可能會報這個錯誤。
如果在安裝的whl過程中,仍然報錯,提示:
> running build_ext
error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
你需要去`http://aka.ms/vcpython27` 下載 `
Microsoft Visual C++ Compiler for Python 2.7
`
安裝完以后,再次執行`pip install *.whl`即可。