MACOSX10.13.6上的Python错误“导入错误:未安装_imaging C模块”

时间:2018-08-22 17:47:41

标签: compiler-errors python-imaging-library image-resizing pgm

我对MACOSX的了解不多。我是MAC新手。我想在MAC上使用Python调整pgm图像的大小。但是显示错误。

这是python代码

from PIL import Image
img=Image.open('secretImage.pgm','r')
columnsize,rowsize=img.size
img = img.resize((2*rowsize,2*columnsize), Image.BILINEAR) # Resize it.
img.save('resized.pgm' ) # Save it back to disk.

错误:

apples-MacBook-Air:untitled folder apple$ python NewFile.py 
Traceback (most recent call last):
  File "NewFile.py", line 4, in <module>
    img = img.resize((2*rowsize,2*columnsize), Image.BILINEAR) # Resize it.
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 1290, in resize
    self.load()
  File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 164, in load
    self.load_prepare()
  File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 231, in load_prepare
    self.im = Image.core.new(self.mode, self.size)
  File "/Library/Python/2.7/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
apples-MacBook-Air:untitled folder apple$ 

我该如何解决?

0 个答案:

没有答案