python中安装第三方模块

Python有两个封装了setuptools的包管理工具:easy_installpip。目前官方推荐使用pip

现在,让我们来安装一个第三方库——Python Imaging Library,这是Python下非常强大的处理图像的工具库。一般来说,第三方库都会在Python官方的pypi.python.org网站注册,要安装一个第三方库,必须先知道该库的名称,可以在官网或者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.7
platform      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 required
library, and set the corresponding ROOT variable in the
setup.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 file
Installing pilprint.py script to /usr/local/bin
Installing pilfile.py script to /usr/local/bin
Installing pilconvert.py script to /usr/local/bin
Installing pildriver.py script to /usr/local/bin
Installing pilfont.py script to /usr/local/bin

Installed /usr/local/lib/python2.7/site-packages/PIL-1.1.7-py2.7-linux-i686.egg
Processing dependencies for PIL
Finished processing dependencies for PIL

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。