title: AWS Lambda using PIL/Pillow with Python 2.7
body: <p>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. </p>
  
  <p>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 <code>pip install pillow -t .</code>, and using pre-compiled PIL libraries from <a href="https://github.com/Miserlou/lambda-packages/tree/master/lambda_packages/Pillow" rel="nofollow noreferrer">here</a> and <a href="https://github.com/ryfeus/lambda-packs/tree/master/Rasterio_osgeo_shapely_PIL_pyproj_numpy/source/PIL" rel="nofollow noreferrer">here</a>. </p>
  
  <p>Using the first pre-compiled source, I get the error: </p>
  
  <blockquote>
    <p>no module named PIL </p>
  </blockquote>
  
  <p>If I rename the subdirectory from PIL to pillow, I get the same error but with pillow. </p>
  
  <p>Using the second pre-compiled source and the pip method, I get the error: </p>
  
  <blockquote>
    <p>Could not import the Python Imaging Library (PIL) required to load image files</p>
  </blockquote>
  
  <p>Here's my import statement and the line that the error is occurring on:</p>
  
  <pre><code>from pillow import *
  ...
  I = imread(filename, flatten=True)
  </code></pre>
  
  <p>Here's a screenshot of my file structure (using the 1st pre-compiled source): 
  <a href="https://i.stack.imgur.com/1YIoc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1YIoc.png" alt="enter image description here"></a></p>
  
  <p>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. </p>
  
  <p>Btw, I've seen <a href="https://stackoverflow.com/questions/37987742/aws-lambda-how-to-use-pillow-library">this</a> question and answer, but I'm not getting the same error message and I couldn't get the suggested commands to work anyway. </p>
  
  <p>I'm wondering if it could be an issue with PIL vs Pillow or with Python 3.6 vs Python 2.7. </p>
  
  <p>Any help is much appreciated!</p>