I am trying to make AWS Lambda function, which uses PIL. Hence I installed PIL inside my project directory with
pip install Pillow -t .
First time it ran on local machine, it caused
ImportError: cannot import name '_imaging'
I though I did something wrong and deleted PIP
and Pillow*
directories from project directory and reinstalled PIL
. Then it worked.
Unfortunately, when I packed everythong into ZIP and posted to AWS, the function started to fail with it again
Traceback (most recent call last):
File "/var/task/myfile.py", line 9, in lambda_handler
from PIL import Image
File "/var/task/PIL/Image.py", line 64, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging'
What is the exact reason of this error and how fix it?
Below are file list in my project dir:
$ ls
bin chardet-3.0.4.dist-info Pillow-5.2.0.dist-info ThumbnailEnergent_Lambda.zip
certifi idna requests myfile.py
certifi-2018.4.16.dist-info idna-2.7.dist-info requests-2.19.1.dist-info urllib3
chardet PIL tests urllib3-1.23.dist-info