本文介绍了如何在PyPy中使用PIL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了一些搜索,但是找不到用于将PIL与PyPy一起使用的tuto.根据PyPy的博客,支持PIL.

I searched a little bit but I couldn't find a tuto to use PIL with PyPy. According to PyPy's blog, PIL is supported.

  • 我在PYTHONPATH中使用pip安装了PIL.
  • 下载后,pip制作2个.pyd文件:_imaging.pyd和_imagingmath.pyd.
  • 安装后,我将%PYTHONPATH%/lib/site-packages/PIL复制到我的PyPy site-packages目录中.
  • 运行脚本(使用PIL)时,它表示无法导入_imaging C模块.

我应该怎么做?

我在Windows 7 x64(python 2.7.1 32bits)上运行它

edit:I run this on Windows 7 x64 (python 2.7.1 32bits)

这是回溯(pypy 1.4.1 Windows二进制):

here is the traceback (pypy 1.4.1 windows binary):

Traceback (most recent call last):
  File "app_main.py", line 53, in run_toplevel
  File "tools\python\gen_images.py", line 52, in <module>
    main()
  File "tools\python\gen_images.py", line 44, in main
    image = Image.open(file)
  File "d:\pypy\site-packages\PIL\Image.py", line 1965, in open
    return factory(fp, filename)
  File "d:\pypy\site-packages\PIL\ImageFile.py", line 91, in __init__
    self._open()
  File "d:\pypy\site-packages\PIL\GifImagePlugin.py", line 97, in _open
    self.seek(0) # get ready to read first frame
  File "d:\pypy\site-packages\PIL\GifImagePlugin.py", line 152, in seek
    self.dispose = Image.core.fill("P", self.size,
  File "d:\pypy\site-packages\PIL\Image.py", line 37, in __getattr__
    raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed

推荐答案

我做到了:

$ /opt/pypy-1.4.1/bin/virtualenv test
$ cd test
$ bin/pip install PIL
...
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.5.2 (e503e483e9ac, Dec 21 2010, 12:02:29)
              [PyPy 1.4.1]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------
... 
$ bin/pypy
Python 2.5.2 (e503e483e9ac, Dec 21 2010, 12:02:29)
[PyPy 1.4.1] on linux2
>>>> import Image
>>>> im = Image.open('/path/to/file.jpg')
>>>> outfile = open('/path/to/file.png', 'wb')
>>>> im.save(outfile, 'png')

像魅力一样工作.那就这样吧. :)

Worked like a charm. So do that. :)

这篇关于如何在PyPy中使用PIL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 23:13