没有名为“成像”的模块

2024-06-08 18:52:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这个问题:

No module named _imagingft

我已经安装了PIL,但它仍然不起作用。我用OSX。

我正在尝试为Django Simple Captcha安装此模块。


Tags: 模块djangonopilsimplecaptchanamedmodule
3条回答

在现有PIL上安装枕头解决了我的问题:

$ sudo easy_install PIL
$ sudo easy_install Pillow

多亏了一系列的资源(最后的功劳),我把下面的脚本放在了一起,这对我来说很有用,但对YMMV来说。(运行前请仔细检查。可能有虫子会吃掉你的肝脏,刮毛你的猫,用含铅的燃料驾驶你的汽车):

#!/bin/bash

pip-2.6 uninstall PIL
# Just in case there's a virtualenv someplace:
pip uninstall PIL
# And forcibly clean up PIL as well
rm -rf /Library/Python/2.6/site-packages/PIL*

if [ ! -d "/usr/X11/include/freetype2" ];then
    echo "You need to have XCode installed with the freetype libraries"
    exit 1
fi

# Ok we're good to install ...
# Freetype is installed by XCode, so let's link to that for PIL's
# setup.py to know where to find things
ln -s /usr/X11/include/freetype2 /usr/local/include/ 
ln -s /usr/X11/include/ft2build.h /usr/local/include/ 
ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/ 
ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/libfreetype.dylib 

pip-2.6 install PIL
# OR
# pip-2.6 install http://effbot.org/downloads/Imaging-1.1.7.tar.gz

学分:

克里斯托弗的建议对我很有效。

详情如下: 一。卸载现有的Python映像库

  1. 下载并提取源版本(从这里 http://effbot.org/downloads/Imaging-1.1.6.tar.gz

  2. 安装freetype2库(您需要freetype,因为 处理用于验证码的TrueType字体)

  3. 修改setup.py(在PIL提取的源文件夹中)以匹配 freetype2库(例如,在我与Centos的VPS上,我更改了“FREETYPE_ROOT=None”行 到“FREETYPE_ROOT=”/usr/local/include“)

  4. 构建PIL(python setup.py Build)并验证Freetype2是否支持 正常

  5. 安装PIL(python setup.py build)

  6. 安装之后,您可以验证库的存在,打开 python控制台并键入“imagingft的导入说明” 图书馆。

如果您使用ubuntu,您可以使用以下手册: http://helloworld.infobart.com/compiling-pil-on-ubuntu-natty

相关问题 更多 >