標籤:
Python有兩個封裝了setuptools的包管理工具:easy_install
和pip
。目前官方推薦使用pip
。
現在,讓我們來安裝一個第三方庫——Python Imaging Library,這是Python下非常強大的處理映像的工具庫。一般來說,第三方庫都會在Python官方的pypi.python.org網站註冊,要安裝一個第三方庫,必須Crowdsourced Security Testing道該庫的名稱,可以在官網或者pypi上搜尋,比如Python Imaging Library的名稱叫PIL,因此,安裝Python Imaging Library的命令就是:
pip install PIL
出現如下問題:
Traceback (most recent call last): File “/usr/bin/pip-python”, line 5, in <module> from pkg_resources import load_entry_point File “build/bdist.linux-x86_64/egg/pkg_resources.py”, line 2749, in <module> File “build/bdist.linux-x86_64/egg/pkg_resources.py”, line 444, in _build_master File “build/bdist.linux-x86_64/egg/pkg_resources.py”, line 725, in require File “build/bdist.linux-x86_64/egg/pkg_resources.py”, line 628, in resolve pkg_resources.DistributionNotFound: pip==0.8
出現上述錯誤主要是由於python的版本太過老了,需要下載最新版本的setuptools
無奈之下,只好去安裝easy_install並安裝。
easy_install PIL
--------------------------------------------------------------------PIL 1.1.7 SETUP SUMMARY--------------------------------------------------------------------version 1.1.7platform linux2 2.7.3 (default, Jul 2 2014, 09:15:41) [GCC 4.8.1]--------------------------------------------------------------------*** TKINTER support not available--- JPEG support available--- ZLIB (PNG/ZIP) support available--- FREETYPE2 support available*** LITTLECMS support not available--------------------------------------------------------------------To add a missing option, make sure you have the requiredlibrary, and set the corresponding ROOT variable in thesetup.py script.To check the build, run the selftest.py script.zip_safe flag not set; analyzing archive contents...Image: module references __file__Adding PIL 1.1.7 to easy-install.pth fileInstalling pilprint.py script to /usr/local/binInstalling pilfile.py script to /usr/local/binInstalling pilconvert.py script to /usr/local/binInstalling pildriver.py script to /usr/local/binInstalling pilfont.py script to /usr/local/binInstalled /usr/local/lib/python2.7/site-packages/PIL-1.1.7-py2.7-linux-i686.eggProcessing dependencies for PILFinished processing dependencies for PIL
python中安裝第三方模組