0

I'm using Python 2.7 (for various reasons) on AWS Lambda, and I need to use the PIL/Pillow library for image processing. I'm using a ZIP file to get code into my Lambda function.

One of the items in this zip is a folder with the PIL library in it. I've tried several different methods of getting the library in there, including using pip install pillow -t ., and using pre-compiled PIL libraries from here and here.

Using the first pre-compiled source, I get the error:

no module named PIL

If I rename the subdirectory from PIL to pillow, I get the same error but with pillow.

Using the second pre-compiled source and the pip method, I get the error:

Could not import the Python Imaging Library (PIL) required to load image files

Here's my import statement and the line that the error is occurring on:

from pillow import *
...
I = imread(filename, flatten=True)

Here's a screenshot of my file structure (using the 1st pre-compiled source): enter image description here

Archive.zip is what I've been uploading to Lambda. Each time I make a code or library change, I recreate this by selecting each of the files I would like to zip, right-clicking and selecting "Compress". I'm using macOS High Sierra.

Btw, I've seen this question and answer, but I'm not getting the same error message and I couldn't get the suggested commands to work anyway.

I'm wondering if it could be an issue with PIL vs Pillow or with Python 3.6 vs Python 2.7.

Any help is much appreciated!

Spencer Goff
  • 1,036
  • 3
  • 14
  • 23

1 Answers1

0

I solved this by using a Docker solution, as outlined in this post.

Pang
  • 9,564
  • 146
  • 81
  • 122
Spencer Goff
  • 1,036
  • 3
  • 14
  • 23