今天在centos中使用pip安装PIL死活不成功,报错:

  Could not find a version that satisfies the requirement PIL (from versions: )
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external PIL to allow).
No matching distribution found for PIL

  

但是使用pip search PIL查找,源中确实有该包:

PIL                                  - Python Imaging Library

google之,得到如下办法(http://stackoverflow.com/questions/21242107/pip-install-pil-dont-install-into-virtualenv):

sudo pip install PIL --allow-external PIL --allow-unverified PIL

果然成功了。

但是程序运行时又报错:

font = ImageFont.truetype(os.path.join("fonts",font_type), font_size)
ImportError: The _imagingft C module is not installed

似乎是没有安装truetype扩展之类的。那就安装吧(http://stackoverflow.com/questions/4011705/python-the-imagingft-c-module-is-not-installed):

sudo yum install freetype-devel

然后卸载、重新安装PIL

sudo pip uninstall PIL
sudo pip install PIL --allow-external PIL --allow-unverified PIL

终于搞定了  

  

PS:之前还尝试过从官网下载PIL源码自己编译安装:

(参照:http://www.cnblogs.com/free--coder/archive/2012/09/12/2681361.html)

1.下载源码并解压:

wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
tar -xzvf Imaging-1.1.7.tar.gz

2.编译安装(注意要root权限):

python setup.py build
python setup.py install

安装倒是成功了,但是python脚本运行时报错:

/usr/lib64/python2.7/site-packages/PIL/Image.py:81: RuntimeWarning: The _imaging extension was built for another  version of Pillow or PIL
warnings.warn(str(v), RuntimeWarning)
Traceback (most recent call last):
File "captcha.py", line 3, in <module>
import Image, ImageDraw, ImageFont, ImageFilter
File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 65, in <module>
raise ImportError("The _imaging extension was built for another "
ImportError: The _imaging extension was built for another version of Pillow or PIL

似乎版本不对。。。。。

放弃了

安装PIL的坑的更多相关文章

  1. Mac osx 安装PIL出现Some externally hosted files were ignored (use --allow-external PIL to allow).

    出现这个问题Some externally hosted files were ignored (use --allow-external PIL to allow)的主要原因是PIL的一些依赖库还没 ...

  2. Mac下安装 PIL

     最近入手MacBook Pro 在配置PIL环境的时候遇到一些问题.现在把解决方式记录下来,希望对有需要的有所帮助. 1. 安装brew : brew 又叫Homebrew,是Mac OSX上的软件 ...

  3. 安装PIL库时提示python未注册错误(自定义python安装路径)

    import sys from _winreg import * # tweak as necessary version = sys.version[:3] installpath = sys.pr ...

  4. 64位Python安装PIL

    写个小程序需要安装PIL,但是官网只有32位,无法找到64位安装路径.根据网上教程自行编译,但是由于VS版本问题总是提示“Python error: Unable to find vcvarsall. ...

  5. Mac系统下安装PIL

    安装PIL依赖JPEG.Freetype.LittleCMS, 首先安装这三个环境(第一至三步): 第一步:安装JPEG http://www.ijg.org/files/jpegsrc.v8c.ta ...

  6. ubuntu Python2.7 安装PIL问题

    $sudo easy_install PIL WARNING: '' not a valid package name; please use only.-separated package name ...

  7. 安装PIL遇到的问题

    配置:Win7 64位 不过折腾到最后,没有使用PIL,官方的PIL很久木有更新了,换了Pillow,是PIL的衍生吧,一直有更新,但是两者不可在同一环境共存. 1 Python version 2. ...

  8. 关于python下安装PIL库遇到的问题及解决办法

    关于python下安装PIL库遇到的问题及解决办法 关于python下安装PIL库遇到的问题及解决办法 :在下面这个网址下载pipllow(a replacement for PIL) www.lfd ...

  9. [转]安装PIL时注册表中找不到python2.7

    如果在win7x64安装python2.7的时候选择了all user,则安装PIL的时候会显示找不到python. 解决办法:复制下面的代码到一个.py文件并运行: # # script to re ...

随机推荐

  1. Win7下安装Oracle 10g

    首先下对版本,Oracle 10g支持Win7版(32位): 10203_vista_w2k8_x86_production_db.zip 10203_vista_w2k8_x86_productio ...

  2. Django2.x版本路由系统的正则写法以及视图函数的返回问题

    一.关于url.py urlpatterns每个元素的不再用url(),而是path(),最重要的一点是,正则的使用需要你自己手动导入re_path,并且在每个使用正则匹配的的元素用re_path() ...

  3. Nginx错误:nginx: [error] OpenEvent("Global\ngx_reload_6252") failed (2: The system cannot find the file specified)

    执行nginx -s reload命令: nginx: [error] OpenEvent("Global\ngx_reload_6252") failed (2: The sys ...

  4. Java Class对象详解

    要怎样在java里来使用一个类,首先必须先把类的.class字节码文件加载进来,然后再进行连接对该类里的域分配内存,最后再调用构造器,如果该类有基类的话,会先去调用基类的构造器,总的来说,分为以下三个 ...

  5. 转:LLVM与Clang的概述及关系

    转:http://www.cnblogs.com/saintlas/p/5738739.html      LLVM是构架编译器(compiler)的框架系统,以C++编写而成,用于优化以任意程序语言 ...

  6. 洛谷 P2947 [USACO09MAR]向右看齐Look Up【单调栈】

    题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again stan ...

  7. 【JavaScript】JS将Java的Timestamp转为Date类型

    遇到一个小需求,由于要填充日期插件里的数据,前台要把java后台传来的Date类型的数据转成YYYY-MM-DD格式的时间数据.通过json传输,Java的Date类型的数据自动转成了时间戳,例如 “ ...

  8. Spring 概念详解

    一.Spring的IoC(Inversion of Control). 这是Spring中得有特点的一部份.IoC又被翻译成“控制反转”,也不知道是谁翻译得这么别扭,感觉很深奥的词.其实,原理很简单, ...

  9. noip 1999 回文数

    题目描述 若一个数(首位不为零)从左向右读与从右向左读都一样,我们就将其称之为回文数. 例如:给定一个10进制数56,将56加65(即把56从右向左读),得到121是一个回文数. 又如:对于10进制数 ...

  10. 【最大流Dinic模板】HDU1532&POJ1273-Drainage Ditches(16/3/6更正)

    #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #inc ...