Windows上Python 3.2的PIL或替代方案?

3 投票
4 回答
17474 浏览
提问于 2025-04-17 02:13

我正在制作我的第一个Python程序 :) 不过,我安装了Python 3.2,而不是2.7,因为新版本自带了TkInter。现在我找不到方法在里面使用PIL。

我看过这个问题,但作为一个完全的新手,这对我帮助不大。我安装了zlib和libjpeg,但在构建pil-py3k时遇到了困难。我对接下来该怎么做一点头绪都没有:

# --------------------------------------------------------------------
# Library pointers.
#
# Use None to look for the libraries in well-known library locations.
# Use a string to specify a single directory, for both the library and
# the include files.  Use a tuple to specify separate directories:
# (libpath, includepath).  Examples:
#
# JPEG_ROOT = "/home/libraries/jpeg-6b"
# TIFF_ROOT = "/opt/tiff/lib", "/opt/tiff/include"
#
# If you have "lib" and "include" directories under a common parent,
# you can use the "libinclude" helper:
#
# TIFF_ROOT = libinclude("/opt/tiff")

FREETYPE_ROOT = None
JPEG_ROOT = None
TIFF_ROOT = None
ZLIB_ROOT = None
TCL_ROOT = None

有没有更简单的方法来让Python 3支持PIL和PNG、JPEG格式?

一个选择是下载旧版本的Python,但那样就没有TkInter了?

我希望你能理解我还是个新手,所以如果我问了什么愚蠢的问题,请多多包涵。Python看起来真的很酷! ;) 任何帮助都非常感谢。

4 个回答

0

正如agf在你提问时提到的,tkinter这个库已经和每个版本的Python一起发布很多年了。最重要的变化是tkinter包的结构调整。最大的变化是基础包的名称:在Python 3.x中,tkinter包叫做tkinter,而在Python 2.x中,这个包叫做Tkinter(注意大写的"T")。你可以查看Python 2.7.2的文档来获取更多关于tkinter的信息。

很遗憾,我没有在Python 3.x中使用过PIL,所以无法提供帮助,但希望你能在2.7版本中完成你需要的工作。

5

我刚发现有一个叫Pillow的PIL分支:https://pypi.python.org/pypi/Pillow/2.1.0

8

对于Python 3.2来说,有一个非官方的PIL(Python Imaging Library)可以使用,答案就在这里:http://www.lfd.uci.edu/~gohlke/pythonlibs/

撰写回答