在服务器上调用import ImageFont时报如下错误

ImportError: The _imagingft C module is not installed

(服务器为Centos5.5, python版本2.7.3)

第一反应是pil安装的有问题,通过yum install freetype-devel libjpeg-devel libpng-devel

把依赖的相关库重新安装一遍,然后通过pip uninstall -y pil卸载pil,然后到http://effbot.org/downloads/Imaging-1.1.7.tar.gz下载源码包,修改set.py中JPEG_ROOT, ZLIB_ROOT,FREETYPE_ROOT等路径,然后执行

python setup.py build_ext -i

python setup.py build

python setup.py install

重新安装完问题依旧。

后来偶然发现官网的一篇文章:http://effbot.org/zone/pil-imaging-not-installed.htm,有所启发,首先判断_imaging是否正常安装,如果安装过程没有报错,在PIL的包下应该能找到,我的在/usr/local/python-2.7.3/lib/python2.7/site-packages/PIL/_imaging.so(文件名后缀因操作系统而异,比如_imaging.pyd或者_imaging.dll),下一步判断python是否能找到_imaging.so,这个通过python -v ,然后执行import Image显示的调试信息中找到_imaging.so是否被导入,如果到这一步都是ok的,那就说明是_imaing.so本身的问题了,果然在python中执行:import _imaing,提示

»> import _imaging

Traceback (most recent call last):

File “<stdin>”, line 1, in <module>

ImportError: libjpeg.so.7: cannot open shared object file: No such file or directory

说明系统在指定的目录找不到libjpeg.so.7这个库,而libjpeg是正常安装的,通过whereis libjpeg.so.7可以找到实际安装路径(/usr/local/lib/libjpeg.so.7),这时只需要在系统的搜索路径下建个软链接到实际安装路径即可(ln -s /usr/local/lib/libjpeg.so.7 /usr/lib/)

whereis libjpeg.so.7的更多相关文章

  1. nginx+mysql+php

    根据生产环境安装操作系统(centos 6.0 64位系统),安装完成后,使用Xshell通过ssh协议连接服务器.ssh 用户名@IP+回车+输入密码后登录系统.#mkdir -p /home/to ...

  2. CentOS下安装libjpeg库及编译GD库

    GD库明明安装了,可处理图片的时候还是报错 Fatal error: Call to undefined function imagecreatefromjpeg() .PHP安装后,默认的gd库不支 ...

  3. Linux下查找文件:which、whereis、locate、find 命令的区别

    我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索.which       查看可执行文件的位置,通过环境变量查whereis    查看文件的位置,通过数据库查,每 ...

  4. linux常用命令-文件搜索命令-locate,which,whereis,grep

    locate 目录或文件名 -i 查找的时候不区分大小写 这个类似everything,速度比find快很多,因为这个命令搜索的是它维护的文件资料库,文件资料库是var/lib/mlocate/mlo ...

  5. Linux常用命令学习2---(文件搜索命令locate find、命令搜索命令whereis which、字符串搜索命令grep、帮助命令man)

     1.文件搜索命令:locate [文件名]    在后台数据库中按文件名搜索,搜索速度比find快,耗费资源更少    例子:locate test.txt,就会显示文件名包含 test.txt的所 ...

  6. 摘要: Linux下which、whereis、locate、find命令的区别

    我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索.这些是从网上找到的资料,因为有时很长时间不会用到,当要用的时候经常弄混了,所以放到这里方便使用. which    ...

  7. whereis 和which

    这两个命令用的好,可以很快找出文件的路径 [root@oc3408554812 zip-3.0]# which passwd/usr/bin/passwd[root@oc3408554812 zip- ...

  8. Linux下的五个查找命令:grep、find、locate、whereis、which

    原文转自 http://www.cnblogs.com/wanqieddy/archive/2011/07/15/2107071.html 1.grep grep(General Regular Ex ...

  9. 每天一个 Linux 命令(17):whereis 命令

    whereis命令只能用于程序名的搜索,而且只搜索二进制文件(参数-b).man说明文件(参数-m)和源代码文件(参数-s).如果省略参数,则返回所有信息. 和find相比,whereis查找的速度非 ...

随机推荐

  1. oracle 索引,组合索引

    1. 组合索引 id,code      组合 id,number  组合 2. 排序cost 使用 id ,cost=0 使用 id+code  cost=0 使用 id+number  cost= ...

  2. FPGA学习中的代码阅读

    不管是学FPGA还是C语言,任何一种代码的学习都离不开大量的代码阅读,也就是多看,多学习别人的代码.初学者在学习的过程中更为重要的是模仿,模仿别人的代码算法怎么去处理的,模仿多了,代码看的多了,能力自 ...

  3. Php header()函数及其常见使用

    语法: Void header(string $string[,bool $replace=true [, int $http_response_code) 向客户端发送原始的HTTP报头 需注意: ...

  4. java.sql.SQLException: No suitable driver

    java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(Unknown Source) at com ...

  5. 第10章 深入理解Session与Cookie

    需要很多Cookie时,考虑HTTP对Cookie数量和大小的限制. 几百或更多台服务器的时候,如何解决Session在多态服务器之间共享的问题. 还有一些安全问题,如Cookie被盗,Cookie伪 ...

  6. gevent异步,io自动切换

    #!/usr/bin/env python # encoding: utf-8  # Date: 2018/6/19 # # from gevent import monkey  # 这俩行必须放在首 ...

  7. 不使用sudo命令执行docker

    不使用sudo命令执行docker  2015-09-11 11:03:05  王春生  8049 最后编辑:王春生 于 2015-09-11 12:18:30 简介:本篇文章介绍如何不使用sudo命 ...

  8. 微信小程序之 wx.getUserInfo引导用户授权问题

    首先,在page外定义一个函数用户判断是否为空对象 var isEmptyObject = function (e) { var temp; for (temp in e) ; } 然后,在page中 ...

  9. 异常:java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/app/userInfoMaint/getProvince.do'

    调试代码时出现异常:java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/app/user ...

  10. coprime Sequence

    Do you know what is called ``Coprime Sequence''? That is a sequence consists of nn positive integers ...