我正在尝试创建一个使用PIL的AWS Lambda函数。因此,我在项目目录中安装了PIL:
这个错误的确切原因是什么,如何修复它?
以下是我项目目录中的文件列表:
pip install Pillow -t .
第一次在本地机器上运行时,它导致了
ImportError: cannot import name '_imaging'
我以为我做错了什么,于是从项目目录中删除了PIP
和Pillow*
目录,并重新安装了PIL
。然后它就正常工作了。
不幸的是,当我将所有内容打包成ZIP并发布到AWS时,该函数再次出现故障。
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'
这个错误的确切原因是什么,如何修复它?
以下是我项目目录中的文件列表:
$ 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